Exemplo n.º 1
0
        /// <summary>
        /// 按分页参数查询结果
        /// </summary>
        public static List <TResult> ToPagingList <TResult>(this IQueryable <TResult> source, IPagingQueryPara para)
        {
            if (!para.QueryTotal)
            {
                return(source.Skip((para.PageIndex - 1) * para.PageSize).Take(para.PageSize).ToList());
            }

            para.Count = source.Count();
            var pageQry = source.Skip((para.PageIndex - 1) * para.PageSize).Take(para.PageSize).ToList();

            return(pageQry);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 按分页参数查询
        /// </summary>
        public static IEnumerable <TResult> PagingQuery <TDb, TResult>(this IReadOnlyList <TDb> dbs, Func <TDb, IQueryable <TResult> > query, IPagingQueryPara para)
            where TDb : ShardingDbContext
        {
            if (!para.QueryTotal)
            {
                return(dbs.PagingQuery(query, (para.PageIndex - 1) * para.PageSize, para.PageSize));
            }

            var pageQry = DoPagingQuery(dbs, query, (para.PageIndex - 1) * para.PageSize, para.PageSize, para.QueryTotal, out var count);

            para.Count = count;
            return(pageQry);
        }