I’m using Entity Framework 4.3. In my SQL Server 2008 db, I have some dates stored as dates rather than datetime.
I need to retrieve data using the date field, here a test code sample:
public static Applicant Create()
{
var dt = new DateTime(1967, 08, 03);
var r = new CrudRepo<Applicant>(UowHelper.GetUow().Context);
return r.Find(a => a.DateOfBirth == dt).Single();
}
However, I’m getting an issue with ‘missing sequence’.
Any ideas as to how I get around this?
I’ll also need to update the database too at some point.
Thanks.
The actual result of
var dt = new DateTime(1967, 08, 03);is8/3/1967 12:00:00 AMThe
DataTypeof theDateOfBirthisDateso we need to TruncateTime the time.msdn: EntityFunctions.TruncateTime Method
or remove the
.Single() methodinstead use the .FirstOrDefault() Method