0

嗨,朋友们,请帮助我摆脱这个使用 lambda 的 linq 新手

select cn from color,related
where cid in (select ciid from related where iid=2)
4

2 回答 2

0

在不知道关系是如何建立的情况下,我能做的最好的就是放手,比如;

(from c in db.color
 from r in db.related
 where c.cid == r.ciid && r.iid == 2
 select c).Distinct();

或者

from c in db.color
where (from r in db.related where r.iid==2 select r.ciid).Contains(c.cid)
select c;
于 2013-08-19T07:16:03.290 回答
0

试试下面的表达式

(from i in dbcontext.color
where (from j in  dbcontext.color where j.iid==2 select j.ciid).contains(i.cid)
select i)
于 2013-08-19T07:17:51.797 回答