Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite TypeHandler not called #2074

Open
karenpayneoregon opened this issue Apr 21, 2024 · 3 comments
Open

SQLite TypeHandler not called #2074

karenpayneoregon opened this issue Apr 21, 2024 · 3 comments

Comments

@karenpayneoregon
Copy link

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
@karenpayneoregon karenpayneoregon changed the title SQLite TypeHandler called SQLite TypeHandler not called Apr 21, 2024
@mgravell
Copy link
Member

mgravell commented Apr 21, 2024 via email

@karenpayneoregon
Copy link
Author

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

@mgravell
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants