Linq如何实现SQL中的 in Linq如何实现如下的SQL语句:
SELECT *
FROM [EMP_REQUIREMENT]
where UUID in
( select distinct REQUIREMENT_ID from EMP_PROJECT where PROJECT_STATUS='3')
分享到:
------解决方案--------------------
本帖最后由 q107770540 于 2013-11-06 18:02:15 编辑
var query=from er in [EMP_REQUIREMENT]
where EMP_PROJECT.Where(p=>p.PROJECT_STATUS==3).Select(p=>p.REQUIREMENT_ID)
.Distinct().Contains(er.UUID)
select er;
------解决方案-------------------- var query1=from p in EMP_PROJECT where p.PROJECT_STATUS=='3'
group p by p.PROJECT_ID into g
select p.FirstOrDefault();
var query2=from q in EMP_REQUIREMENT where query1.Contains(q.UUID ) select q; ------解决方案--------------------