title: C# LINQ multiple one to many includes with where condition
body: <p>I can't find the correct query to get all the data I need. </p>
  
  <p>I've got three sample tables:</p>
  
  <ul>
  <li>Employee (Id, Name, Telephone) </li>
  <li>EmployeeDepartment (Id, EmployeeId, DepartmentId)</li>
  <li>DepartmentAddress (Id, DepartmentId, City,
  Street, IsActive...)</li>
  </ul>
  
  <p>Each of this tables has one-to-many relation with next one. An Employee can be assigned to many departments and one department can have many addresses assigned.</p>
  
  <p>I'm trying to write an Entity Framework query which will return, for example, all employees which are assigned to department in City of New York. My problem is that I don't want just employees. I need it to also include all properties of EmployeeDepartment and DepartmentAddress in Employee class.</p>
  
  <p>What I'm trying to do is something like:</p>
  
  <pre><code>var matchingEmployees = ctx.Employee
  .Include("EmployeeDepartment")
  .Include("EmployeeDepartment.DepartmentAddress")
  .Where(p=&gt; p.EmployeeDepartment
  .Where(x=&gt;x.DepartmentAddress.Where(y=&gt;y.City == "New York)))
  .ToList();
  </code></pre>
  
  <p>As a result I get all Departments and all EmployeeDepartments, when I need only ones matching Where condition.  What query will return the data I need?</p>