Exemple #1
0
 protected virtual ISelect <TEntity> ApplyPaging(ISelect <TEntity> query, TGetListInput input)
 {
     if (input is IPagingDto pageDto)
     {
         return(query.Page(pageDto.Page + 1, pageDto.Size));
     }
     return(query);
 }
Exemple #2
0
        /// <summary>
        /// Creates the asynchronous.
        /// </summary>
        /// <typeparam name="TInput">The type of the input.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns></returns>
        public static async Task <PagedList <T> > CreateAsync <TInput>(ISelect <TInput> source, int pageNumber, int pageSize, IMapper mapper) where TInput : class
        {
            var count = await source.CountAsync();

            var items = await source.Page(pageNumber, pageSize).ToListAsync();

            return(new PagedList <T>(mapper.Map <List <T> >(items), count, pageNumber, pageSize));
        }
Exemple #3
0
        /// <summary>
        /// Creates the asynchronous.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="pageNumber">The page number.</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <returns></returns>
        public static async Task <PagedList <T> > CreateAsync(ISelect <T> source, int pageNumber, int pageSize)
        {
            var count = await source.CountAsync();

            var items = await source.Page(pageNumber, pageSize).ToListAsync();

            return(new PagedList <T>(items, count, pageNumber, pageSize));
        }
Exemple #4
0
        protected virtual ISelect <TEntity> ApplyPaging(ISelect <TEntity> query, TGetListInput input)
        {
            //Try to use paging if available
            if (input is IPageDto pageDto)
            {
                return(query.Page(pageDto.Page + 1, pageDto.Count));
            }

            //No paging
            return(query);
        }
        public static Page <T> ToPage <T>(this ISelect <T> select, int page, int size) where T : class
        {
            Page <T> result = new Page <T>();

            var data = select.Page(page, size).Count(out long total).ToList <T>();

            result.TotalItems   = total;
            result.Items        = data;
            result.ItemsPerPage = size;
            result.CurrentPage  = page;
            result.TotalPages   = (long)Math.Ceiling(result.TotalItems / (double)size);
            return(result);
        }
        public async Task <List <T> > SelectAsync <T, TNavigate>(Expression <Func <T, bool> > whereExp = null, IEnumerable <T> ids = null, Expression <Func <T, TNavigate> > navigateExp = null, int pageIndex = 0, int pageSize = 0, DbTransaction transaction = null)
            where T : DatabaseModel
            where TNavigate : DatabaseModel
        {
            ISelect <T> select = sql.Select <T>(ids).Where(whereExp).Include(navigateExp).WithTransaction(transaction);

            if (pageSize > 0)
            {
                select = select.Page(pageIndex, pageSize);
            }

            return(await select.ToListAsync());
        }
Exemple #7
0
        public PagedResultDto <User> Get([FromQuery] PageDto pageDto)
        {
            ISelect <User> selectPost = _fsql
                                        .Select <User>();

            List <User> lists = selectPost
                                .Page(pageDto.PageNumber, pageDto.PageSize)
                                .ToList();

            long total = selectPost.Count();

            return(new PagedResultDto <User>(total, lists));
        }
Exemple #8
0
        public async Task <List <TightenModel> > GetTightensAsync(string code, DateTime sTime, DateTime endTime, int page, int pagesize)
        {
            if (FreeHanlder.SqliteHandler == null)
            {
                throw new NullReferenceException("未初始化SqliteHandler数据库访问程序;");
            }
            ISelect <TightenModel> query = FreeHanlder.SqliteHandler.Select <TightenModel>()
                                           .Where(t => t.EngineCode.Contains(code));

            if (sTime != null)
            {
                query = query.Where(t => t.CreateTime > sTime);
            }
            if (endTime != null)
            {
                query = query.Where(t => t.CreateTime < endTime);
            }
            return(await query.Page(page, pagesize).NoTracking().ToListAsync());
        }
Exemple #9
0
        /// <summary>
        /// FreeSql query state
        /// </summary>
        /// <param name="select"></param>
        /// <param name="currentPageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="includeNestedMembers"></param>
        public FreeSqlQueryState(ISelect <T> select, int currentPageNumber, int pageSize, bool includeNestedMembers)
        {
            if (select == null)
            {
                throw new ArgumentNullException(nameof(select));
            }

            if (currentPageNumber < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(currentPageNumber), $"{nameof(currentPageNumber)} can not be less than zero");
            }

            if (pageSize < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize), $"{nameof(pageSize)} can not be less than zero");
            }

            _mLazyFreeSqlQueryMembers = new Lazy <IEnumerable <T> >(() => select.Page(currentPageNumber, pageSize).ToList(includeNestedMembers));
        }
Exemple #10
0
 public static ISelect <T> Page <T>(this ISelect <T> source, PageDto pageDto) where T : class, new()
 {
     return(source.Page(pageDto.PageNumber, pageDto.PageNumber));
 }
 public static List <TEntity> ToPagerList <TEntity>(this ISelect <TEntity> source, PageDto pageDto, out long count) where TEntity : class
 {
     count = source.Count();
     //Page 方法是从1开始
     return(source.Page(pageDto.Page + 1, pageDto.Count).ToList());
 }