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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -