SQLite TypeHandler not called
karenpayneoregon opened this issue · 3 comments
karenpayneoregon commented
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
mgravell commented
Well that seems odd, especially for the write path (the read path is
trickier because of the weak type model in sqlite) - however 2.1.44 is
hidden currently precisely because of a reported problem around Date only -
is it possibly related? Does it fail in 2.1.35?
…On Sun, 21 Apr 2024, 19:09 Karen Payne, ***@***.***> wrote:
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
—
Reply to this email directly, view it on GitHub
<#2074> or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAEHMD7K6LDIINMZTOAHJTY6P6G3BFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJLJONZXKZNENZQW2ZNLORUHEZLBMRPXI6LQMWBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTLDTOVRGUZLDORPXI6LQMWSUS43TOVS2M5DPOBUWG44SQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLJZRGYYTGMZUGWBKI5DZOBS2K2LTON2WLJLWMFWHKZNKGIZDKNJRHE4TINRWU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you are subscribed to this thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
karenpayneoregon commented
No it does not fail with 2.1.35, works as expected.
mgravell commented
K, adding to my bucket of #fail for this morning