lambda - Passing a comparison function as a parameter into Entity Framework -



lambda - Passing a comparison function as a parameter into Entity Framework -

i have couple of entity framework functions differ in operators, e.g.

public int getcountequal(int i) { homecoming context.entity.where(e => e.value == i).count(); } public int getcountless(int i) { homecoming context.entity.where(e => e.value < i).count(); } public int getcountlessorequal(int i) { homecoming context.entity.where(e => e.value <= i).count(); }

and on. obviously, dumbed downwards version of real program...

i guess must possible somehow pass operator parameter / lambda look (since they're sort of canonical), whatever i've tried far along lines results in infamous "the linq look node type 'invoke' not supported in linq entities." error.

any hints how pass comparing function parameter can translated sql? query needs run @ database level, can't load entities memory , run lambda there...

public int getcount(expression<func<entity, bool>> whereexpression) { homecoming context.entity.where(whereexpression).count(); } int countequal = getcountequal(e => e.value == i); int countless = getcountequal(e => e.value < i); int countlessorequal = getcountequal(e => e.value <= i);

entity-framework lambda

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -