entity framework - How to apply a reusable linq expression to a EF navigation property -
i have next look (simplified):
from p in providers select new { p.name, p.accounts.count(a => a.state == 2) };
this works fine, want create reusable look so:
expression<func<account, bool>> mypredicate() { homecoming => a.state == 2; }
and utilize so:
from p in providers select new { p.name, p.accounts.count(mypredicate()) }
this unfortunately doesn't work because navigation property (accounts) ilist or icollection in ef. what's pattern here? happy alter things around little, note i'm not after dynamic expressions reusable ones.
linq entity-framework
No comments:
Post a Comment