我想通过方法中的传入process_Id选择不在表Process_Systems中的所有系统,我已经写了SQL但是现在我需要LINQ ..请帮帮我 如何将这样的SQL查询转换为LINQ:
SELECT *
FROM Systems
WHERE id NOT IN (
SELECT systemid
FROM Process_Systems
WHERE processId = 4
);
或者这个(这些是相同的)
SELECT Systems.*
FROM Systems LEFT JOIN Process_Systems ps
ON ps.systemId = Systems.id
AND ps.processId = 4
WHERE ps.systemId IS NULL;
答案 0 :(得分:0)
var query = from system in Systems
where id != (from process_system in Process_Systems
where process_system.processId == 4
select process_system.systemid).First()
select system;
最后你将获得IEnumerable对象。如果我有你的问题。