2013-06-21 46 views
0

有兩個列表"ObjlistA""ObjlistB".有沒有辦法在Where子句中循環?

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

你想查詢我們在SQL中的位置,即testCol IN('A','B','C')..?這是否有點...? –

回答

4

這是你在找什麼?

var newList = ObjlistB.Where(someObj => ObjlistA.Any(a => a.SomeProperty == someObj.SomeProperty)) 
0
where ObjlistA.Any(x => x.Property == someObj.Property) 
0

你的意思呢?

var newList = from someObg in ObjlistB 
        where ObjlistA.Any(a => a.ID == someObg.ID) 
        select someObg; 
相關問題