title: Apply Include and ThenInclude based on Lambda Expressions Dictionary
body: <p>I have a few Entity Framework 7 (Core) entities:</p>
  
  <pre><code>public class Person {
     public virtual Address Address { get; set; }
     public virtual ICollection&lt;Hobby&gt; Hobbies { get; set; }
  }
  
  public class Address {
     public String Street { get; set; }
     public virtual Country Country { get; set; }
  }
  </code></pre>
  
  <p>And I have a string array as follows:</p>
  
  <pre><code>String[] entities = new String[] { "Hobbies", "Address.Country" }
  </code></pre>
  
  <p>Given this string array I got:</p>
  
  <pre><code>context.Persons
    .Include(x =&gt; x.Hobbies)
    .Include(x =&gt; x.Address).ThenInclude(x =&gt; x.Country);
  </code></pre>
  
  <p>In EF6 I could do something like:</p>
  
  <pre><code>context.Persons.Include(entities[0]).Include(entities[1]);
  </code></pre>
  
  <p>But in EF7 Include does not allow strings. I created the dictionary:</p>
  
  <pre><code>private readonly Dictionary&lt;String, LambdaExpression&gt; _properties = new Dictionary&lt;String, LambdaExpression&gt;();
  </code></pre>
  
  <p>Which would have something like:</p>
  
  <pre><code>x =&gt; x.Hobbies is for "Hobbies"
  x =&gt; x.Address.Country is for "Address.Country"     
  </code></pre>
  
  <p>And I have the extension:</p>
  
  <pre><code>public static IQueryable&lt;T&gt; Include&lt;T&gt;(this IQueryable&lt;T&gt; source, Dictionary&lt;String, LambdaExpression&gt; properties) {
  }
  </code></pre>
  
  <p>Where I need to given the Dictionary apply the following:</p>
  
  <ol>
  <li><p>For "x => x.Hobbies" just do:  </p>
  
  <pre><code> source.Include(x =&gt; x.Hobbies);
  </code></pre></li>
  <li><p>If the expression is something like "x => x.Address.Country" add:  </p>
  
  <pre><code> source.Include(x =&gt; x.Address).ThenInclude(x =&gt; x.Country);
  </code></pre></li>
  </ol>
  
  <p>Can this be done?</p>