Linq query list contains a list?

I think you want either: ListObjectB. Where(p => p.ListOfObjectA. Any(x => ListOfIdsA.

Contains(x. Id))) or ListObjectB. Where(p => p.ListOfObjectA.

All(x => ListOfIdsA. Contains(x.Id))) (You may well want to make ListOfIdsA a HashSet.

I think you want either: ListObjectB. Where(p => p.ListOfObjectA. Any(x => ListOfIdsA.

Contains(x. Id))) or ListObjectB. Where(p => p.ListOfObjectA.

All(x => ListOfIdsA. Contains(x.Id))) (You may well want to make ListOfIdsA a HashSet if it's of significant size, btw. ).

Learn something new every day...for some reason I was thinking Extension methods were the way to solve this one. – Justin Niessner Mar 2 '10 at 15:12 I want it any of them. Thx for the prompt response (it was my first question in here, and damn, that was fast!) – Berto Mar 2 '10 at 15:21 @Justin: Well Where, All and Any are extension methods :) – Jon Skeet Mar 2 '10 at 15:35 Doh!

Poorly worded comment. I was referring to hand rolling my own Extension Methods. – Justin Niessner Mar 2 '10 at 16:04 1 @BZ: That's already what the query is doing.

I think another question (with a short but complete example) probably would be useful, yes. – Jon Skeet Mar 2 '107 at 5:20.

So I have two lists: One of ObjectB (ListObjectB) and Another contains a list of id's of ObjectA (called ListOfIdsA). If this I want to get a list of ObjectB where ObjectB. ListOfObjectA is in the ListOfIdsA.

But this obviously trows an exception. I google it, stackoverflowed, but I'm thinking that my search skills aren't going so well in this, can anybody give a ninja awser of this?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions