Reputation: 1963
I want to read from the table by datetime. If I use this:
(from x in Db.Table where x.Date.Value == DateTime.Now select x).ToList();
my code throws EntityCommandExecutionException:
A failure occurred while giving parameter information to OLE DB provider
So I use this:
(from x in Db.Table where DbFunctions.TruncateTime(x.Date) == DateTime.Now select x).ToList();
but it is very slowly (about 40 seconds). In my table is approximately 500 000 records.
Thanks for advice
Upvotes: 1
Views: 189
Reputation: 4776
define now property first and then query like following:
var now = DateTime.Now;
var list = Db.Table.Where(e=>e.Date == now).ToList();
Or:
(from x in Db.Table where x.Date == now select x).ToList();
Upvotes: 1