Closed DanieleSky closed 3 years ago
You can create your own implementation of IPropertyResolver
to achieve this. For example, extend the DefaultPropertyResolver
implementation and override protected virtual HashSet<Type> PrimitiveType
. Then register your implementation with DommelMapper.SetPropertyResolver()
at application startup.
https://github.com/henkmollema/Dommel/blob/master/src/Dommel/DefaultPropertyResolver.cs#L47
Thanks, works perfectly. For others, this is my implementation:
public class MyPropertyResolver : DefaultPropertyResolver
{
protected override HashSet<Type> PrimitiveTypes
{
get
{
//add Date type like primitive for Dommel
base.PrimitiveTypes.Add(typeof(Date));
//add the type map for Dapper
SqlMapper.AddTypeMap(typeof(Date), DbType.DateTime);
return base.PrimitiveTypes;
}
}
}
Hi, I need to save in my SQL Server database a column with only date part of DateTime. I created a struct like this:
used in:
and mapped like this:
With Get method I can obtain the column value thanks the conversion operators. But when I try to update a entity, the SQL generated don't have the LastLoginDate field.
Using Dapper directly all works thanks the AddTypeMap and implementing IConvertible interface
for example:
How I can do this with Dommel? Thanks