dimanche 26 avril 2015

How to do DateTime Comparison in C# Entity Function?

I have certain date time saved in my database, my requirement is to get only those records which are newer than saved date-time.

I tried this code

DateTime last_date_time_saved = GetLastDateTimeFromDB();

List<Item> li = con.Items.Where(p => p.TimeModified > last_date_saved).ToList();
return li;

But it causes error Could not execute the specified command:

Error parsing Date value [26/04/2015 16:42:56]."}

I have tried Convert.ToDateTime function but it still does not resolve the problem.

What is the best way to compare date time in this case?

Aucun commentaire:

Enregistrer un commentaire