Reputation: 9
There are two lists "ObjlistA"
and "ObjlistB".
var newList = from someObg i ObglistB
where [condition = true if some property of any element in the list ObjlistAA equals someObg's some property]
select someObg
Is there a way to loop inside the where clause, so that the obj's property can be compared with each and every element's property in the list? Can anyone help me out the "Where" part?
Upvotes: 0
Views: 660
Reputation: 120286
Is this what you're looking for?
var newList = ObjlistB.Where(someObj => ObjlistA.Any(a => a.SomeProperty == someObj.SomeProperty))
Upvotes: 4
Reputation: 4892
you mean this?
var newList = from someObg in ObjlistB
where ObjlistA.Any(a => a.ID == someObg.ID)
select someObg;
Upvotes: 0