title: How do i make .Include to work on an IEnumerable
body: <p>I'm having trouble running a query on my repository. I have to fetch a product by the id and display it in an edit view alongside the image of the product.</p>
  
  <p>There is a method in my ProductRepository that implements Get() i.e fetch all the product and GetByID as the name implies. I implemented a generic repository pattern with a unit of work class like below</p>
  
  <pre><code>public class GenericRepository&lt;TEntity&gt; where TEntity : class
      {
          internal SchoolContext context;
          internal DbSet&lt;TEntity&gt; dbSet;
  
          public GenericRepository(SchoolContext context)
          {
              this.context = context;
              this.dbSet = context.Set&lt;TEntity&gt;();
          }
  
          public virtual IEnumerable&lt;TEntity&gt; Get(
              Expression&lt;Func&lt;TEntity, bool&gt;&gt; filter = null,
              Func&lt;IQueryable&lt;TEntity&gt;, IOrderedQueryable&lt;TEntity&gt;&gt; orderBy = null,
              string includeProperties = "")
          {
              IQueryable&lt;TEntity&gt; query = dbSet;
  
              if (filter != null)
              {
                  query = query.Where(filter);
              }
  
              foreach (var includeProperty in includeProperties.Split
                  (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
              {
                  query = query.Include(includeProperty);
              }
  
              if (orderBy != null)
              {
                  return orderBy(query).ToList();
              }
              else
              {
                  return query.ToList();
              }
          }
  
          public virtual TEntity GetByID(object id)
          {
              return dbSet.Find(id);
          }
  </code></pre>
  
  <p>I think thats the only relevant code block. The problem arises when i try to run a query that i found in a tutorial to fetch the product alongside the image with the query below</p>
  
  <pre><code>Product product = db.Products.Include(s =&gt; s.Files).SingleOrDefault(s =&gt; s.ID == id);
  </code></pre>
  
  <p>I cant use db.Products because i'm using a unit of work class so i have to run the query with <code>_unit.ProductRepository.GetByID().Include(s =&gt; s.Files).SingleOrDefault(s =&gt; s.ID == id);</code></p>
  
  <p>However this does not seem to be possible and i'm stucked.</p>