public virtual async Task <IEnumerable <T> > GetAll(int includeDepth = 0, Expression <Func <T, bool> > filter = null) { var query = filter != null?Entities.Where(filter) : Entities; if (includeDepth > 0) { //Cycles are not allowed in no-tracking queries. Add AsTracking to a dbSet or uncomment FindInverse() in the GetAllPaths return(await query.Include(Context.GetAllPaths(typeof(T), includeDepth)).ToListAsync()); } return(await query.ToListAsync()); }
public virtual async Task <IEnumerable <T> > GetBySingleId(int id, bool useFirstId, int includeDepth = 0, Expression <Func <T, bool> > filter = null) { var(conditionExpression, parameterExpression) = CreateSingleIdExpressionArguments(id, useFirstId); var query = filter != null?Entities.Where(filter) : Entities; query = query.Where( Expression.Lambda <Func <T, bool> >(conditionExpression, parameterExpression)); if (includeDepth > 0) { return(await query.Include(Context.GetAllPaths(typeof(T), includeDepth)).ToListAsync()); } return(await query.ToListAsync()); }