I have an implementation of a Generic Repository in Entity Framework which I am trying to improve to use the .Include(..) function provided by EF instead of including the na
You can use the params Expression
instead of string parameter
public IQueryable GetAll(
Expression> filter = null,
Func, IOrderedQueryable> orderBy = null,
params Expression>[] includeProperties)
{
IQueryable query = dbSet;
if (filter != null)
{
query = query.Where(filter);
}
foreach (var includeProperty in includeProperties)
{
query = query.Include(includeProperty);
}
if (orderBy != null)
{
return orderBy(query);
}
else
{
return query;
}
}