protected virtual SortBuilder <TModel> GetPagedQuery(QueryBuilder <TModel> query, PagingSpec <TModel> pagingSpec) { return(query.Where(pagingSpec.FilterExpression) .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) .Skip(pagingSpec.PagingOffset()) .Take(pagingSpec.PageSize)); }
public virtual PagingSpec <TModel> GetPaged(PagingSpec <TModel> pagingSpec) { var pagingQuery = Query.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) .Skip(pagingSpec.PagingOffset()) .Take(pagingSpec.PageSize); pagingSpec.Records = pagingQuery.ToList(); //TODO: Use the same query for count and records pagingSpec.TotalRecords = Count(); return(pagingSpec); }
protected virtual SortBuilder <TModel> GetPagedQuery(QueryBuilder <TModel> query, PagingSpec <TModel> pagingSpec) { var filterExpressions = pagingSpec.FilterExpressions; var sortQuery = query.Where(filterExpressions.FirstOrDefault()); if (filterExpressions.Count > 1) { // Start at the second item for the AndWhere clauses for (var i = 1; i < filterExpressions.Count; i++) { sortQuery.AndWhere(filterExpressions[i]); } } return(sortQuery.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) .Skip(pagingSpec.PagingOffset()) .Take(pagingSpec.PageSize)); }
protected virtual SortBuilder <TModel> GetPagedQuery(QueryBuilder <TModel> query, PagingSpec <TModel> pagingSpec) { return(query.Where(pagingSpec.FilterExpression) .OrderBy(pagingSpec.OrderByClause(x => x.Id), pagingSpec.ToSortDirection())); }