Using repository pattern to eager load entities using ThenIclude : <p>My application uses Entity Framework 7 and the repository pattern.</p>

<p>The GetById method on the repository supports eager loading of child entities:</p>

<pre><code>    public virtual TEntity GetById(int id, params Expression&lt;Func&lt;TEntity, object&gt;&gt;[] paths)
    {
        var result = this.Set.Include(paths.First());
        foreach (var path in paths.Skip(1))
        {
            result = result.Include(path);
        }
        return result.FirstOrDefault(e =&gt; e.Id == id);
    }
</code></pre>

<p>Usage is as follows to retrieve a product (whose id is 2) along with the orders and the parts associated with that product:</p>

<pre><code>productRepository.GetById(2, p =&gt; p.Orders, p =&gt; p.Parts);
</code></pre>

<p>I want to enhance this method to support eager loading of entities nested deeper than one level. For example suppose an <code>Order</code> has its own collection of <code>LineItem</code>'s. </p>

<p>Prior to EF7 I believe the following would have been possible to also retrieve the LineItems associated with each order:</p>

<pre><code>productRepository.GetById(2, p =&gt; p.Orders.Select(o =&gt; o.LineItems), p =&gt; p.Parts);
</code></pre>

<p>However this doesn't appear to be supported in EF7. Instead there is a new ThenInclude method that retrieves additional levels of nested entities:</p>

<p><a href="https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015" rel="noreferrer">https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015</a></p>

<p>I am unsure as to how to update my repository to support retrieval of multiple-levels of eager loaded entities using <code>ThenInclude</code>. </p>
