DapperLib/Dapper

SQLite TypeHandler not called

karenpayneoregon opened this issue · 3 comments

Used the following handler with SQL-Server, works as expected.

public class DateOnlyTypeHandler : SqlMapper.TypeHandler<DateOnly>
{
    public override void SetValue(IDbDataParameter parameter, DateOnly date)
    {
        parameter.Value = date.ToString("yyyy-MM-dd");
    }

    public override DateOnly Parse(object value)
        => DateOnly.FromDateTime((DateTime)value);
}

Setup

internal class DapperOperation
{

    private readonly IDbConnection _cn;

    public DapperOperation()
    {
        _cn = new SqlConnection(ConnectionString());
        SqlMapper.AddTypeHandler(new SqlDateOnlyTypeHandler());
    }

Problem

Tried this with SQLite.Core with SQLiteConnection and neither SetValue nor Parse are executed which I learned by a) inspecting values sent to the database b) setting breakpoints.

  • Dapper 2.1.44
  • System.Data.SQLite.Core 1.0.118
  • VS2022 17.9.2
  • NET8

No it does not fail with 2.1.35, works as expected.

K, adding to my bucket of #fail for this morning