I'm looking for a way to Load nested relationships with a where clause.
Imagine that query example below.
select *
from directors d
inner join managers m
on d.id = m.director
inner join employees e
on m.id = e.manager
where e.name = 'John'
It's easy to load all the information from those entities by doing this:
ctx.Directors.Include(x => x.Managers.Select(y => y.Employees)).ToList();
but how can I simulate my where clause at the query posted above?
Knowing that I'm using Entity Framework 6, is it possible to do that? I have researched for this and didn't find an answer to my question.
EDIT 1
I'm asking this, because I'm trying to use this in a WCF Restful aplication. And it's returning with a StackOverflowException, probably because of a circular reference when I build the backward reference for the entities.
ctx.Directors.Include(x => x.Managers.Select(y => y.Employees).Where(z => z.name == "John")).ToList();doesn't works?