I\'ve a little problem. Assuming a Entity like this
public class FirstEntity
{
public int ID { get; set; }
public string Prop1 { get; set; }
publ
Parameterize with a Func
.
And instead of .Select(r => r)
you can simply use .AsQueryable()
.
public IQueryable GetBySpecification(ISpecification spec = null, bool tracking = true, params Func, IQueryable>[] includes)
{
var query = _context.Set().AsQueryable();
if (!tracking)
query = query.AsNoTracking();
if (includes != null)
foreach (var include in includes)
query = include(query);
if (spec != null)
query = query.Where(spec.Expression);
return query;
}
return GetBySpecification(
includes: new Func, IQueryable>[]
{
(q) => q.Include(u => u.Roles).ThenInclude(r => r.Permissions),
});