Hi ,
I have a datetime field that i want to compare only the date part of it with another date in a LINQ query , but an error is thrown , here is a code snippet :
var currentDate = DateTime.UtcNow.Date;
var contacts = (from c in service.ContactSet
&& c.new_testDate.Value.Date.Equals(currentDate)
select c
).ToList();
the error :
"Invalid 'where' condition. An entity member is invoking an invalid property or method."
is it a LINQ limitation ? and how can we solve it ? Thanks.
There are solutions here, please have a look and choose the best one for you.
www.codeproject.com/.../LINQ-query-to-compare-only-date-part-of-DateTime
@Erhan Keskin , same error
can you try this please?
where c.new_testDate.Value.Date == currentDate
Edit :
Here is the write code snippet :
var currentDate = DateTime.UtcNow.Date;
var contacts = (from c in service.ContactSet
where c.new_testDate.Value.Date.Equals(currentDate)
select c
).ToList();
Siv Sagar
149
Super User 2025 Season 1
Vahid Ghafarpour
80
Super User 2025 Season 1
Mansi Soni
74