How to write Repository method for .ThenInclude in EF Core 2 : <p>I'm trying to write a repository method for Entity Framework Core 2.0 that can handle returning child collections of properties using .ThenInclude, but I'm having trouble with the second expression. Here is a working method for .Include, which will return child properties (you supply a list of lambdas) of your entity.</p>

<pre><code>public T GetSingle(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Expression&lt;Func&lt;T, object&gt;&gt;[] includeProperties)
{
    IQueryable&lt;T&gt; query = _context.Set&lt;T&gt;();
    foreach (var includeProperty in includeProperties)
    {
        query = query.Include(includeProperty);
    } 

    return query.Where(predicate).FirstOrDefault();
}
</code></pre>

<p>Now here is my attempt at writing a method that will take a Tuple of two Expressions and feed those into a .Include(a => a.someChild).ThenInclude(b => b.aChildOfSomeChild) chain. This isn't a perfect solution because it only handles one child of a child, but it's a start. </p>

<pre><code>public T GetSingle(Expression&lt;Func&lt;T, bool&gt;&gt; predicate, params Tuple&lt;Expression&lt;Func&lt;T, object&gt;&gt;, Expression&lt;Func&lt;T, object&gt;&gt;&gt;[] includeProperties)
{
    IQueryable&lt;T&gt; query = _context.Set&lt;T&gt;();
    foreach (var includeProperty in includeProperties)
    {
         query = query.Include(includeProperty.Item1).ThenInclude(includeProperty.Item2);              
    }

    return query.Where(predicate).FirstOrDefault();
}
</code></pre>

<p>Intellisense returns an error saying "The type cannot be inferred from the usage, try specifying the type explicitly". I have a feeling it's because the expression in Item2 needs to be classified as somehow related to Item1, because it needs to know about the child relationship it has. </p>

<p>Any ideas or better techniques for writing a method like this?  </p>
