I'd like to create a convention to set the column that are named as "Id" to be primary key, I've been looking at the documentacion and so far I've foud ony to do it manually class by class like: with dommel:
public class ProductMap : DommelEntityMap<TEntity>
{
public ProductMap()
{
Map(p => p.Id).IsKey();
}
}
I'd like something more like:
public ConventionMap()
{
Properties<int>().Where(p=>p.Name.ToLower()=="id").isKey();
}
it could be dommel or dapper extensions or any other, I just this implementation to be fluent.
any advice? thanks!
Dommel allows you to create a custom
IKeyPropertyResolver.Your implementation would look like:
Which should be registered at application start-up using this line of code:
You don't need Dapper.FluentMap (or Dapper.FluentMap.Dommel) for this. Also see: the documentation.