Hi How can I write the following sql query by linq
Select * From Employee where EmployeeId not开发者_如何学Go in (Select EmployeeId in orders)
You can try either this:
var query = from e in context.Employees
let ids = context.Orders.Select(o => o.Employee.Id)
where !ids.Contains(e.Id)
select e;
or this:
var query = from e in context.Employees
where !context.Orders.Any(o => o.Empolyee.Id == e.Id)
select e;
精彩评论