title: Entity Framework nested navigation properties count only
body: <p>I have three model classes</p>
  
  <pre><code>public class Item1{
  
      public int Id;
  
      public List&lt;Item2&gt; Item2List { get; set; }
  }
  
  public class Item2{
      public int Id;
  
      //this is the FK
      public int Item1Id {get;set;}
  
      public Item1 Item1 {get;set;}
  
      //Not in db. Ignored field in EntityTypeConfiguration
      public int Item3Count;
  
      public List&lt;Item3&gt; Item3List { get; set; }
  }
  
  public class Item3{
      public int Id;
  
      //this is the FK
      public int Item2Id {get;set;}
  
      public Item2 Item2 {get;set;}    
  }
  </code></pre>
  
  <p>I want to return the list of Item1 along with list of associated Item2, and load the COUNT of Item3List associated with Item 2 without loading the Item3List.</p>
  
  <p>Here is what I am doing right now:</p>
  
  <pre><code>public IEnumerable&lt;Item1&gt; GetItems()
  {
      return base.Query().Include(item1 =&gt; item1.Item2List.Select(item2 =&gt; item2.Item3List)).ToList();
  }
  </code></pre>
  
  <p>This returns me the list of all 3 objects Item1, Item2 and Item3. But I only need the count of Item3List in Item3Count, and not the entire Item3List list. How can I achieve that? I tried this below, but it throws error.</p>
  
  <pre><code>return base.Query().Include(item1 =&gt; item1.Item2List.Select(item2 =&gt; new Item2 {
  Item3Count = item2.Item3List.Count()
  })).ToList();
  </code></pre>
  
  <blockquote>
    <p>The Include path expression must refer to a navigation property
    defined on the type. Use dotted paths for reference navigation
    properties and the Select operator for collection navigation
    properties. Parameter name: path</p>
  </blockquote>