Filter a list of objects using a property that is another list. Usign linq.
Posted
by Luís Custódio
on Stack Overflow
See other posts from Stack Overflow
or by Luís Custódio
Published on 2010-04-19T21:09:21Z
Indexed on
2010/04/19
21:13 UTC
Read the original article
Hit count: 271
I've a nice situation, I think at beginning this a usual query but I'm having some problem trying to solve this, the situation is:
I've a list of "Houses", and each house have a list of "Windows". And I want to filter for a catalog only the Houses witch have a Blue windows, so my extension method of House is something like:
public static List<House> FilterByWindow (this IEnumerable<House> houses, Window blueOne){
houses.Select(p=>p.Windows.Where(q=>q.Color == blueOne.Color));
return houses.ToList();
}
Is this correct or I'm losing something? Some better suggestion?
© Stack Overflow or respective owner