title: Explicit loading of grandchild collections in EF 4.1
body: <p>Given the following model ...</p>
  
  <pre><code>public class Parent
  {
      public int Id { get; set; }
      public ICollection&lt;Child&gt; Children { get; set; }
  }
  
  public class Child
  {
      public int Id { get; set; }
      public ICollection&lt;Grandchild&gt; Grandchildren { get; set; }
  }
  
  public class Grandchild
  {
      public int Id { get; set; }
  }
  </code></pre>
  
  <p>... we can <strong>eager load</strong> with <code>Include</code> a <code>Parent</code> with all <code>Children</code> and <code>Grandchildren</code> in one step like so:</p>
  
  <pre><code>context.Parents.Include(p =&gt; p.Children.Select(c =&gt; c.Grandchildren))
  </code></pre>
  
  <p>Is something similar possible for <strong>explicit loading</strong>?</p>
  
  <p>The child collection can be explicitely loaded this way:</p>
  
  <pre><code>Parent parent = context.Parents.Find(parentId);
  context.Entry(parent).Collection(p =&gt; p.Children).Load();
  </code></pre>
  
  <p>But trying to load the children in a similar way as with <code>Include</code> ...</p>
  
  <pre><code>context.Entry(parent)
      .Collection(p =&gt; p.Children.Select(c =&gt; c.Grandchildren)).Load();
  </code></pre>
  
  <p>... doesn't compile und the string overload of <code>Collection</code> ...</p>
  
  <pre><code>context.Entry(parent).Collection("Children.Grandchildren").Load();
  </code></pre>
  
  <p>... throws an exception ("...no dotted paths allowed...").</p>
  
  <p>The only thing which I found working is to explicitely load the <code>Grandchildren</code> in a loop:</p>
  
  <pre><code>Parent parent = context.Parents.Find(parentId);
  context.Entry(parent).Collection(p =&gt; p.Children).Load();
  foreach (var child in parent.Children)
      context.Entry(child).Collection(c =&gt; c.GrandChildren).Load();
  </code></pre>
  
  <p>I am wondering if I missed something and if there is some other way to explicitely load the <code>GrandChildren</code> in one roundtrip.</p>
  
  <p>Thanks for feedback in advance!</p>