Nullable DateTime and Dapper Dot Net
Asked Answered
M

0

6

I have a Type with a nullable DateTime column. When I try to use Dapper Dot Net to create a collection of that Type, I run into problems.

Scenario 1: If all the rows are null for this column it's fine

Scenario 2: If one or more the rows have a date value for this column, I get the following error:

Error parsing column 3 (LastCompleted=2013-12-03 00:00:00 - DateTime) - Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.

It's probably worth noting that I am using Dapper in a .NET 3.5 repository library - which seems to be fine, except for this issue.

If this is a known issue, then no problem, but I can't find anything specifically relating to Nullable DateTime in Dapper.

Mauriciomaurie answered 4/12, 2013 at 11:55 Comment(6)
You've come to the right place, Dapper backs StackOverflow :-)Ceric
Ha yeah :) So fingers crossed....Mauriciomaurie
Just an update if anybody ever reads this. I've had to give up on Nullable DateTime with Dapper. It works sometimes. I errors sometimes. And nobody is answering...Mauriciomaurie
I'm looking on the Dapper site now to see what issues are around... can't see anything as yet. Usually Marc Gravell takes these questions.Ceric
@AdamHouldsworth Thanks Adam. Would be interesting to see if Marc or anybody picks this up.Mauriciomaurie
I've been trying to reproduce the behaviour you are describing with no success -- just to to be sure, may you show us some code?Birkett

© 2022 - 2024 — McMap. All rights reserved.