Hi如何通过 linq 编写以下 sql 查询
Select * From Employee where EmployeeId not in (Select EmployeeId in orders)
你可以试试这个:
var query = from e in context.Employees
let ids = context.Orders.Select(o => o.Employee.Id)
where !ids.Contains(e.Id)
select e;
或者这个:
var query = from e in context.Employees
where !context.Orders.Any(o => o.Empolyee.Id == e.Id)
select e;