Change your method to look like this:
public IEnumerable<TEntity> GetAll(string[] includes)
{
var query = this.dbEntitySet;
foreach (var include in includes)
query = query.Include(include);
return query;
}
The Include
method does not mutate the DbSet
, it only returns you a new DbQuery
with your include.