How can I convert this sql statetment to LINQ to Entities?
SQL Statement:
Select * from Departments where DepartmentID in (Select DepartmentID from Empl
(from d in db.Departments
join e in db.Employees
on d.DepartmentID equals e.DepartmentID
where e.FirstName.Contains("FirstName") ||
e.LastName.Contains("LastName")
select t).Distinct()
u could use this
var x =
(from t0 in db.Employees
where
t0.FirstName.Contains("FirstName") ||
t0.LastName.Contains("LastName")
select new {
t0.DepartmentID
}).FirstOrDefault().DepartmentID;
from t in db.Departments
where
t.DepartmentID.contains(x.DepartmentID)
select t