如何在Linq中使用IN子句

ZKF3340320

我有一个如下的Sql查询,请帮助我如何在Linq中编写确切的查询。谢谢

select count(ExpiredProjectID) from AssignedExpiredProjects where ExpiredProjectID IN (select id from ExpiredProjectsTracking)
km

试试这个代码......

var projIDs= (from ept in _context.ExpiredProjectsTracking
              select ept.id).ToList();

int resultCount= (from apt in _context.AssignedExpiredProjects
                  where projIDs.Contains(apt.ExpiredProjectID)
                  select apt.ExpiredProjectID).Count();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章