2008-09-05 122 views

回答

9
from a in TableA 
where (from b in TableB 
     join c in TableC on b.id equals c.id 
     where .. select b.id) 
.Contains(a.Id) 
select new { a.Id, a.Name } 
1

LIN在LIN中沒有對IN的支持。您需要加入2個查詢。

4

LINQ以contains的形式支持IN。認爲「collection.Contains(id)」,而不是「id IN(collection)」。

from a in TableA 
where (
    from b in TableB 
    join c in TableC 
     on b.id equals c.id 
    select b.id 
).Contains(TableA.Id) 
select new { a.Id, a.Name } 

另請參閱本博文post

相關問題