I'm a bit stuck on this. Basically I want to do something like the following SQL query in LINQ to SQL:
select Image from dbo.Employee where ID in(Select ID from dbo.Department where IsActive=1)
Any help would be gratefully received.
Thanks.
I'm a bit stuck on this. Basically I want to do something like the following SQL query in LINQ to SQL:
select Image from dbo.Employee where ID in(Select ID from dbo.Department where IsActive=1)
Any help would be gratefully received.
Thanks.
You can force the point with a subquery as in the question @IswantoSan links to (how to do subquery in LINQ) but, without knowing more about your entity relationships, why wouldn't simply use a join here?
from e in Employees
join d in Departments on e.ID equals d.ID
where d.IsActive
select e.Image
select Image from dbo.Employee
.Where(u =>
dbo.Employee
.Where(x => u.IsActive = 1)
.Select(x.ID)
)
Is the query that will work for you.