编写特殊的linq查询

问题描述:

嗨 我如何通过linq编写followingin tsql查询:

Hi How can I write the followin tsql query by linq:

Select * From employees where EmployeeId not in(select EmployeeId from Orders)


谢谢

通常,您可以使用 Linqer [
Generally you can use Linqer[^] to convert any SQL statement to LINQ.



For your question the tsql will look like this.
var query =
    from e in Employees
    where !(from o in Orders
            select o.EmployeeID)
           .Contains(e.EmployeeID)
    select e;



希望对您有帮助.



I hope this helps you well.