我有一个Sql查询如下,请帮我如何在Linq中编写确切的查询。感谢
select count(ExpiredProjectID) from AssignedExpiredProjects where ExpiredProjectID IN (select id from ExpiredProjectsTracking)
答案 0 :(得分:1)
试试这段代码......
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();
答案 1 :(得分:0)
var searchList = context.ExpiredProjectsTracking.ToList();
var sum = context.AssignedExpiredProjects.Count(x => searchList.Contains(x.Id))