title: Getting Entity Framework to eager load on Group By
body: <p>I know that changing the shape of a query causes Entity Framework to ignore the include calls but is there a way I can get it to load the sub properties when I do a select many and a group by. In the following example I want to notify all the employees who have a job booked in a certain time period. Calling .ToArray() after the where only hits the database once but I am doing the SelectMany and GroupBy in memory. Is there a way I can get the SelectMany and the GroupBy to happen on the SQL server and still include the ServiceType and Ship and the Employee details?</p>
  
  <p>I am looking for a way to make one SQL call to the database and end up with a list of Employees who have a job in the time period and the jobs they are assigned to.</p>
  
  <pre><code>var employeeJobs = DataContext.Jobs.
      Include("ServiceType").
      Include("Ship").
      Include("JobEmployees.Employee").
      Where(j =&gt; j.Start &gt;= now &amp;&amp; j.Start &lt;= finish).
      OrderBy(j =&gt; j.Start).
      ToArray().
      SelectMany(j =&gt; j.JobEmployees, (j, je) =&gt; new { 
          Job = j, 
          Employee = je.Employee 
      }).GroupBy(j =&gt; j.Employee);
  </code></pre>