title: ThenInclude in Entity Framework .net core 2.0
body: <p>I have nested models called <code>PositionLevel</code>, <code>PositionLevelCompanyLookup</code>, <code>Company</code>, <code>CompanySub</code>. I want to get all data of the models in the <code>GetDetail</code> function with <code>ThenInclude</code>. But all data of the model's didn't get and I couldn't see a reason for that. </p>
  
  <p>How do I do that?</p>
  
  <pre><code>public class PositionLevel : DynexModel
  {
      public string Description { get; set; }
      [JsonIgnore]
      public List&lt;PositionLevelCompanyLookup&gt; Companies { get; set; }
  
      [NotMapped]
      public virtual List&lt;Company&gt; CompanyList =&gt; this.Companies?.Select(p =&gt; p.Company).ToList();
  }
  
  public class PositionLevelCompanyLookup : DynexModel
  {
      public int PositionLevelId { get; set; }
      public PositionLevel PositionLevel { get; set; }
  
      public int CompanyId { get; set; }
      public Company Company { get; set; }
  }
  
  public class Company : DynexModel
  {
      public string Name { get; set; }
      [JsonIgnore]
      public List&lt;CompanySub&gt; SubCompanies { get; set; }
  
      [NotMapped]
      public virtual List&lt;Company&gt; SubCompanyList =&gt; this.SubCompanies?.Select(p =&gt; p.SubCompany).ToList();
  }
  
  public class CompanySub : DynexModel
  {
          public int CompanyId { get; set; }
          public Company Company { get; set; }
  
          public int SubCompanyId { get; set; }
          public Company SubCompany { get; set; }
  }
  
  public ActionResult&lt;PositionLevel&gt; GetDetail(int id)
  {
      var res = _context.Entity&lt;PositionLevel&gt;()
               .Include(p =&gt; p.Companies)
               .ThenInclude(p =&gt; p.Company)
               .ThenInclude(p =&gt; p.SubCompanies)
               .FirstOrDefault(p =&gt; p.Id == id);
  
      return res ;
   }
  </code></pre>