title: Entity Framework - Eager loading with filter?
body: <p>I'm working with a DB schema where records are not overwritten when updated. Rather a new copy of the record is added and marked as "current". </p>
  
  <p>For example:</p>
  
  <pre><code>Id | Current | Name | Owner
  1  | false   | Foo  | Bar
  1  | false   | Foo  | Bazz
  1  | true    | Foo  | Buzz
  </code></pre>
  
  <p>In my model I have a <code>Blog</code> entity that has many <code>Post</code>s related to it. Each <code>Post</code> has many <code>Comment</code>s related to it:</p>
  
  <pre><code>public class Blog
  {
      public int Id {get; set};
      public bool Current {get; set};
      public ICollection&lt;Post&gt; Posts {get; set;}
  }
  
  public class Post
  {
      public int Id {get; set};
      public bool Current {get; set};
      public ICollection&lt;Comment&gt; Comments {get; set;}
  }
  
  public class Comment
  {
      public int Id {get; set};
      public bool Current {get; set};
  }
  </code></pre>
  
  <p>I would like to eagerly load a <code>Blog</code> with all its <code>Post</code>s and all their <code>Comment</code>s much like in <a href="https://msdn.microsoft.com/en-us/library/jj574232(v=vs.113).aspx" rel="nofollow noreferrer">this example from MSDN</a>:</p>
  
  <blockquote>
    <p><code>
    using (var context = new BloggingContext()) 
    { 
        // Load all blogs, all related posts, and all related comments 
        var blogs1 = context.Blogs 
                           .Include(b =&gt; b.Posts.Select(p =&gt; p.Comments)) 
                           .ToList(); 
    }
    </code></p>
  </blockquote>
  
  <p>However, I would like to only include DB records where <code>Current == true</code>. How can I do this with LINQ-to-EF? Ideally the condition would go into the <code>JOIN</code>'s <code>ON</code> clause - is this possible?</p>