Exemple #1
0
        public virtual Task <List <T> > GetPageListAsync(List <IConditionalModel> conditionalList, PageModel page, Expression <Func <T, object> > orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
        {
            RefAsync <int> count  = 0;
            var            result = Context.Queryable <T>().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(conditionalList).ToPageListAsync(page.PageIndex, page.PageSize, count);

            page.PageCount = count;
            return(result);
        }
Exemple #2
0
        public virtual Task <List <T> > GetPageListAsync(List <IConditionalModel> conditionalList, PageModel page)
        {
            RefAsync <int> count  = 0;
            var            result = Context.Queryable <T>().Where(conditionalList).ToPageListAsync(page.PageIndex, page.PageSize, count);

            page.PageCount = count;
            return(result);
        }
Exemple #3
0
        public virtual async Task <List <T> > GetPageListAsync(Expression <Func <T, bool> > whereExpression, PageModel page, Expression <Func <T, object> > orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
        {
            RefAsync <int> count  = 0;
            var            result = await Context.Queryable <T>().OrderByIF(orderByExpression != null, orderByExpression, orderByType).Where(whereExpression).ToPageListAsync(page.PageIndex, page.PageSize, count);

            page.TotalCount = count;
            return(result);
        }
Exemple #4
0
        public virtual Task <List <T> > GetPageListAsync(Expression <Func <T, bool> > whereExpression, PageModel page)
        {
            RefAsync <int> count  = 0;
            var            result = Context.Queryable <T>().Where(whereExpression).ToPageListAsync(page.PageIndex, page.PageSize, count);

            page.PageCount = count;
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// 分页拓展
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public static async Task <SqlSugarPagedList <TEntity> > ToPagedListAsync <TEntity>(this ISugarQueryable <TEntity> entity, int pageIndex, int pageSize)
            where TEntity : new()
        {
            RefAsync <int> totalCount = 0;
            var            items      = await entity.ToPageListAsync(pageIndex, pageSize, totalCount);

            var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);

            return(new SqlSugarPagedList <TEntity>
            {
                PageIndex = pageIndex,
                PageSize = pageSize,
                Items = items,
                TotalCount = (int)totalCount,
                TotalPages = totalPages,
                HasNextPages = pageIndex < totalPages,
                HasPrevPages = pageIndex - 1 > 0
            });
        }