如何将此 sql 语句转换为 LINQ to Entities?
SQL 语句:
Select * from Departments where DepartmentID in (Select DepartmentID from Employees where FirstName like '%FirstName%' or LastName like '%LastName%')
我所拥有的只是 WHERE =(equals) ,我不能执行 WHERE IN 子句
LINQ 到实体:
from t in db.Departments
where
t.DepartmentID == -->Should be IN not EQUALS
((from t0 in db.Employees
where
t0.FirstName.Contains("FirstName") ||
t0.LastName.Contains("LastName")
select new {
t0.DepartmentID
}).FirstOrDefault().DepartmentID)
select t