有两个列表"ObjlistA"
和"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
有没有办法在where子句中循环,以便可以将obj的属性与列表中的每个元素的属性进行比较? 任何人都可以帮我解决“Where”部分吗?
答案 0 :(得分:4)
这是你要找的吗?
var newList = ObjlistB.Where(someObj => ObjlistA.Any(a => a.SomeProperty == someObj.SomeProperty))
答案 1 :(得分:0)
where ObjlistA.Any(x => x.Property == someObj.Property)
答案 2 :(得分:0)
var newList = from someObg in ObjlistB
where ObjlistA.Any(a => a.ID == someObg.ID)
select someObg;