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

Open Beginner friendly
#2,269 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
backend, database

Research direction

Start by locating the existing PagingInfo and BasePagingInfo types and the Page query entry point. Confirm how Count and PageSize are exposed, then add the requested PageCount behavior and verify it through the project’s existing pagination tests or query tests, if available.

Written by the indexing model from the issue text.

Description

问题点,好多分页控件需要的参数为 页大小 (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;
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnetcore/FreeSql

All issues in dotnetcore/FreeSql

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.