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

SqlMapper.TypeHandler<DateTime?> not working with SQLite #742

Open
ImGonaRot opened this issue Apr 15, 2017 · 2 comments
Open

SqlMapper.TypeHandler<DateTime?> not working with SQLite #742

ImGonaRot opened this issue Apr 15, 2017 · 2 comments

Comments

@ImGonaRot
Copy link

ImGonaRot commented Apr 15, 2017

I have a SQLite database with a table that has a column defined as the following:
CreatedDate DateTime DEFAULT (date('now')),

While using Dapper Execute command, I can insert a new record just fine with with or without CreatedDate
BUT if I try to use Dapper Query either with a class or dynamic it will throw an error saying the following:

String was not recognized as a valid DateTime.

So I then proceeded to create a new SqlMapper.TypeHandler<DateTime?> like the following:
#295

I added
Dapper.SqlMapper.AddTypeHandler(new NullableDateTimeHandler.Default);

But the NullableDateTimeHandler SetValue and Parse never get called.

I then went into SQLite I changed the CreatedDate to a DateTimeOffet
CreatedDate DateTimeOffest DEFAULT (date('now')),
Which is not a know SQLite data type.
And then change the TypeHandler<DateTimeOffset?>...

Then it works.

So for some reason I can't get SqlMapper.TypeHandler<DateTime?> to work with SQLite but I can get it to work with custom types "aka DateTimeOffset?".

What am I doing wrong?

@agnusha
Copy link

agnusha commented Dec 11, 2020

Same problem

@AmirMahdyJebreily
Copy link

same problem

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

3 participants