我必须列出要分配给“员工”的所有“shift”数据,但如果员工数据中已存在轮类数据,则不得包含该数据。让我们看看图像样本。
这个查询解决了这个问题。我在这里找到了这个:
Scott's Blog
select * from shift where not exists
(select 1 from employeeshift where shift.shiftid = employeeshift.shiftid
and employeeshift.empid = 57);
让我们看看结果:
现在我的问题是,我怎样才能在 linQ 中做到这一点?我正在使用 Entity Framework 。
希望有人能帮忙。非常感谢!!!
最佳答案
from s in context.shift
where !context.employeeshift.Any(es=>(es.shiftid==s.shiftid)&&(es.empid==57))
select s;
希望对你有帮助
关于c# - 如何使用 LINQ 选择 WHERE NOT EXIST?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9031008/