linq-to-sql combine .any expression
Posted
by Victor
on Stack Overflow
See other posts from Stack Overflow
or by Victor
Published on 2010-05-01T04:32:17Z
Indexed on
2010/05/01
4:37 UTC
Read the original article
Hit count: 364
linq-to-sql
|LINQ
I need to filter out parent by property value of child collection. I am doing something like this:
var results = (from c in db.Customers where
c.Orders.Any(o => o.Status = (int)Status.Ordered)
select c;
It's fine but now I need to filter by 2 values, i.e. take all parent records that have any chilren records that have BOTH values:
var results = (from c in db.Customers where
c.Orders.Any(o => o.Status == (int)Status.Ordered) && (o.Status == (int).Shipped))
select c;
Trying something obvious like this doesn't work.
© Stack Overflow or respective owner