I'm not sure what you are trying to achieve using such approach, but if you strongly want to pass two params
parameters in your method, you can merge them into one params
, just need also pass number of one of them. Like this (notice Take
and Skip
there):
public IEnumerable<DeviceInstance> GetFiltered(
Func<IQueryable<DeviceInstance>, IOrderedQueryable<DeviceInstance>> orderBy = null,
int? Page = 0,
int numberOfIncludeExpressions = 0,
params System.Linq.Expressions.Expression<Func<DeviceInstance, bool>>[] expressions)
{
IQueryable<DeviceInstance> query = dbSet;
if (expressions != null)
{
foreach (var z in expressions.Take(numberOfIncludeExpressions))
{
query = query.Include(z);
}
foreach (var z in expressions.Skip(numberOfIncludeExpressions))
{
query = query.Where(z);
}
}
if (orderBy != null)
{
return orderBy(query).ToList();
}
else
{
return query.ToList();
}
}