ClickHouse.Client
ClickHouse.Client copied to clipboard
SqlMapper.TypeHandler not working
Hi cannot convert datetime to another type.
public class PersianDateTimeHandler : SqlMapper.TypeHandler<PersianDateTime>
{
public static readonly PersianDateTimeHandler Default = new PersianDateTimeHandler();
public override void SetValue(IDbDataParameter parameter, PersianDateTime value)
{
parameter.Value = value.ToDateTime();
}
public override PersianDateTime Parse(object value)
{
return ((DateTime)value).ToPD();
}
}
SqlMapper.AddTypeHandler(PersianDateTimeHandler.Default);
SqlMapper.AddTypeMap(typeof(PersianDateTime), DbType.DateTime);
SqlMapper.AddTypeMap(typeof(PersianDateTime?), DbType.DateTime);
SqlMapper.AddTypeMap(typeof(PersianDateTime), DbType.DateTime2);
SqlMapper.AddTypeMap(typeof(PersianDateTime?), DbType.DateTime2);
SqlMapper.AddTypeMap(typeof(PersianDateTime), DbType.DateTimeOffset);
SqlMapper.AddTypeMap(typeof(PersianDateTime?), DbType.DateTimeOffset);
This sounds more like a question to Dapper developers?
in your driver does not work .
in other driver like postgres work correctly.