c# - Can't translate method into a store expression -


this question has answer here:

the closest questions i've found this one , far can see, it's not regarding same issue. might mistaken, in case, hope can explain how similarity goes (except same words referring error, is). being said, have following issue.

this works supposed to.

list<typo> things = context.things.where(thing => thing.nice).tolist(); 

this, however, doesn't.

list<typo> things = context.things.where(thing => isnice(thing)).tolist(); ... private bool isnice(typo thing) { return thing.nice; } 

context of type modelcontainer deriving dbcontext. i've been told it's standard setup ef , have no reason suspect otherwise. error message claims following.

{"linq entities not recognize method xxx method, , method cannot translated store expression."}

i have no experience error and, frankly, research i've made gave me little clarity. can (a) make work my way , (b) investigate further.

you can't use own method in lambda expression of linq entities, if encapsulates entities properties because linq entities doesn't know how translate them valid sql statement.

for getting methods working must entities database valid linq entities query , fill them c# collection (like list). can use extension methods .asenumerable(), .tolist(), select(), ...

here have list of .net methods linq entities can translate , can use in lambda expression, brief explanation of exception:

clr method canonical function mapping

and here have list linq methods supported linq entities:

supported linq methods


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -