The 'XXX' property on 'XXX' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.DateTime'

entity-framework

Question

I am writing a select query in lambda expression in which one of the column name (ResolveDate) is null, and I am getting the following error:

The 'ResolveDate' property on 'Ticket' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.DateTime'.

How can I set this column nullable? I mean that if column is null in my query result it should not give error?

1
2
12/27/2013 11:59:46 AM

Accepted Answer

DateTime is a reference type. You need to use Nullable DateTime in your class.

DateTime? ResolveDate = null;

or

Nullable<DateTime> ResolveDate ;
8
12/27/2013 12:01:28 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow