c# - LINQ to Entities does not recognize the method? -
var tmp = productdbset.where(x => x.lastupdate >= datetime.minvalue && x.lastupdate.value.tostring("mm/yyyy") == curmonth).select(x => x.id);
while run above code, got error message:
linq entities not recognize method 'system.string tostring(system.string)' method, , method cannot translated store expression.
also tried,
var tmp = productdbset.where(x => x.lastupdate >= datetime.minvalue && x.lastupdate.value.tostring("mm/yyyy") == curmonth).tolist().select(x => x.id);
but same,
how can solve that?
as error message telling you, tostring
method of datetime
isn't supported.
since you're trying determine if month , year of date match given value, can compare actual month , year, rather trying string containing month , year compare with.
x.lastupdate.value.year == yeartocomparewith && x.lastupdate.value.month = monthtocomparewith
Comments
Post a Comment