title: Custom function for Include method in EF
body: <p>I create ASP.NET Core 1 application with EF Core 1. I have two class which has one-to-many relationship as follow</p>
  
  <pre><code> public class Country: EntityBase
   {
      public string Name { get; set; }
  
      // fields for relations
  
      public IQueryable&lt;Singer&gt; Singers { get; set; }
   }
  
   public class Singer : EntityBase
   {
      public string Name { get; set; }
  
      // fields for relation
  
      public int CountryId { get; set; }
      public virtual Country Country { get; set; }
   }
  </code></pre>
  
  <p>And their mapping </p>
  
  <pre><code> public class SingerMap
   {
      public SingerMap(EntityTypeBuilder&lt;Singer&gt; entityBuilder)
      {
          entityBuilder.HasKey(x =&gt; x.Id);
          entityBuilder.Property(x =&gt; x.Id).ValueGeneratedOnAdd();
  
          entityBuilder.Property(x =&gt; x.Name).HasMaxLength(500);
  
          //relational fields
          entityBuilder.HasOne(x =&gt; x.Country).WithMany(x =&gt; x.Singers).HasForeignKey(x =&gt; x.CountryId);
      }
   }
  
   public class CountryMap
   {
      public CountryMap(EntityTypeBuilder&lt;Country&gt; entityBuilder)
      {
          entityBuilder.HasKey(x =&gt; x.Id);
          entityBuilder.Property(x =&gt; x.Id).ValueGeneratedOnAdd();
          entityBuilder.Property(x =&gt; x.Name).HasMaxLength(500);
      }
   }
  </code></pre>
  
  <p>I create generic Repository pattern for this entities. There is a function for include  property as follow</p>
  
  <pre><code>  public virtual IEnumerable&lt;T&gt; AllIncluding(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.AsEnumerable();
      }
  </code></pre>
  
  <p>And I call this method</p>
  
  <pre><code>    [HttpGet]
      public JsonResult GetAllForIndex()
      {
          var result = Service.AllIncluding(x =&gt; x.Country);
          return Json(result);
      }
  </code></pre>
  
  <p>And after this I get this error</p>
  
  <blockquote>
    <p>The type of navigation property 'Singers' on the entity type 'Country'
    is 'IQueryable' for which it was not possible to create a
    concrete instance. Either initialize the property before use, add a
    public parameterless constructor to the type, or use a type which can
    be assigned a HashSet&lt;> or List&lt;>.</p>
  </blockquote>
  
  <p>I have not any idea for solution.
  Please help.</p>