public static IFetchSpecification <T> ThenByDescending <T>( this IFetchSpecification <T> specification, Expression <Func <T, object> > keySelector) { return(specification .ThenBy(OrderingDirection.Descending, keySelector)); }
public static IFetchSpecification <T> TakePage <T>( this IFetchSpecification <T> specification, int pageNumber, int pageSize) { return(specification .TakePage(new PaginationExpression(pageSize, pageNumber))); }
public IEnumerable <TEntity> Find( ISpecification <TEntity>?specification = null, IFetchSpecification <TEntity>?fetchSpecification = null) { return(_dbSet .Evaluate(specification) .EvaluateFetch(fetchSpecification)); }
public static IFetchSpecification <T> ThenInclude <T, TPreviousProperty, TProperty>( this IFetchSpecification <T> specification, Expression <Func <TPreviousProperty, TProperty> > keySelector) { var lastInclude = specification.Include.Last(); ((IncludeExpression <T>)lastInclude).ThenInclude(keySelector); return(specification); }
public static IFetchSpecification <T> WithNoOrder <T>( this IFetchSpecification <T> specification) { return(new FetchSpecification <T> ( include: specification.Include, orderBy: null, takePage: specification.TakePage )); }
private static IFetchSpecification <T> TakePage <T>( this IFetchSpecification <T> specification, PaginationExpression?takePage) { return(new FetchSpecification <T> ( include: specification.Include, orderBy: specification.OrderBy, takePage: takePage )); }
private static IFetchSpecification <T> OrderBy <T>( this IFetchSpecification <T> specification, OrderingDirection direction, Expression <Func <T, object> > keySelector) { return(new FetchSpecification <T> ( include: specification.Include, orderBy: new[] { new OrderingExpression <T>(direction, keySelector), }, takePage: specification.TakePage )); }
private static IFetchSpecification <T> ThenBy <T>( this IFetchSpecification <T> specification, OrderingDirection direction, Expression <Func <T, object> > keySelector) { var orderBy = specification.OrderBy.ToList(); orderBy.Add(new OrderingExpression <T>(direction, keySelector)); return(new FetchSpecification <T> ( include: specification.Include, orderBy: orderBy, takePage: specification.TakePage )); }
internal static IQueryable <TEntity> EvaluateFetch <TEntity>( this IQueryable <TEntity> query, IFetchSpecification <TEntity>?specification) where TEntity : class { if (specification == null) { return(query); } foreach (var includeExpression in specification.Include) { query = (IQueryable <TEntity>)includeExpression.AddIncludes(query); } for (var i = 0; i < specification.OrderBy.Count; i++) { var(direction, keySelector) = specification.OrderBy[i]; switch (direction) { case OrderingDirection.Ascending: query = i == 0 ? query.OrderBy(keySelector) : ((IOrderedQueryable <TEntity>)query).ThenBy(keySelector); break; case OrderingDirection.Descending: query = i == 0 ? query.OrderByDescending(keySelector) : ((IOrderedQueryable <TEntity>)query).ThenByDescending(keySelector); break; } } if (specification.TakePage != null) { var(pageSize, pageIndex) = specification.TakePage; query = query .Skip(pageSize * pageIndex) .Take(pageSize); } return(query); }
public static IFetchSpecification <T> Include <T, TProperty>( this IFetchSpecification <T> specification, Expression <Func <T, TProperty> > keySelector) { var includes = new List <IIncludeExpression <T> >(); if (specification.Include.Any()) { includes.AddRange(specification.Include); } var includeExpr = new IncludeExpression <T>(); includeExpr.Include <T, TProperty>(keySelector); includes.Add(includeExpr); return(new FetchSpecification <T> ( include: includes, orderBy: specification.OrderBy, takePage: specification.TakePage )); }
public static IFetchSpecification <T> TakeAll <T>( this IFetchSpecification <T> specification) { return(specification .TakePage(null)); }
public IEnumerable <TEntity> Find( ISpecification <TEntity>?specification = null, IFetchSpecification <TEntity>?fetchSpecification = null) { throw new NotImplementedException(); }