Skip to content

希望分页中加入页数量(PageCount)属性,不用每次自己计算 #2269

Description

@ping9719

问题点,好多分页控件需要的参数为 页大小 (PageCount)而不是 总数量(Count)导致我每次都需要自己去计算页大小,确实较麻烦。

希望将 PagingInfo 类加入到 FreeSql 中

    public class PagingInfo : BasePagingInfo
    {
        public PagingInfo(int pageNumber, int pageSize = 20) : base()
        {
            base.PageNumber = pageNumber;
            base.PageSize = pageSize;
        }

        /// <summary>
        /// 页大小
        /// </summary>
        public int PageCount { get => Math.Max(1, (int)Math.Ceiling(Count / (double)PageSize)); }
    }

使用方式

                PagingInfo pagingInfo = new PagingInfo(PageIndex, PageSize);
                DataList = await DataDb.db.Queryable<User>().Page(pagingInfo).ToListAsync();
                PageCount = pagingInfo.PageCount;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions