Esempio n. 1
0
 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));
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 protected virtual SortBuilder <TModel> GetPagedQuery(QueryBuilder <TModel> query, PagingSpec <TModel> pagingSpec)
 {
     return(query.Where(pagingSpec.FilterExpression)
            .OrderBy(pagingSpec.OrderByClause(x => x.Id), pagingSpec.ToSortDirection()));
 }