title: Shaping EF LINQ Query Results Using Multi-Table Includes
body: <p>I have a simple LINQ EF query below using the method syntax.  I'm using my Include statement to join  four tables: Event and Doc are the two main tables, EventDoc is a many-to-many link table, and DocUsage is a lookup table.</p>
  
  <p>My challenge is that I'd like to shape my results by only selecting specific columns from each of the four tables.  But, the compiler is giving a compiler is giving me the following error:</p>
  
  <p>'System.Data.Objects.DataClasses.EntityCollection does not contain a definition for "Doc' and no extension method 'Doc' accepting a first argument of type 'System.Data.Objects.DataClasses.EntityCollection' could be found.</p>
  
  <p>I'm sure this is something easy but I'm not figuring it out.  I haven't been able to find an example of someone using the multi-table include but also shaping the projection.</p>
  
  <p>Thx,Mark</p>
  
  <pre><code>var qry= context.Event
      .Include("EventDoc.Doc.DocUsage")
      .Select(n =&gt; new
      {
          n.EventDate,
          n.EventDoc.Doc.Filename,  //&lt;=COMPILER ERROR HERE
          n.EventDoc.Doc.DocUsage.Usage
      })
      .ToList();
  
      EventDoc ed;
      Doc d = ed.Doc;  //&lt;=NO COMPILER ERROR SO I KNOW MY MODEL'S CORRECT
      DocUsage du = d.DocUsage;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/9KsZ1.png" alt="alt text"><img src="https://i.stack.imgur.com/k4F7F.png" alt="alt text"></p>