linq to entities - Entity Framework apply filter to parent and child object -


trying keep description simple, let's assume have order object contains list of lineitem objects.

i need apply filter can quite complex find orders based on lineitem criteria. simplified example:

var orders = db.order.where(o => o.lineitems.any(li => li.price == 1.00)); 

this give me correct orders, when expand order.lineitems, lineitems, not ones filtered.

it seems need apply filter again order.lineitems each order process? said earlier, selection criteria quite complex 30 or more clauses.

is there simpler way write query?

the following return lineitems grouped order

var ligroups = db.lineitems.where(li => li.price == 1.00).groupby(li => li.order); 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -