Lingya.Pagination 1.0.8-CI-20231117-065651

This is a prerelease version of Lingya.Pagination.
dotnet add package Lingya.Pagination --version 1.0.8-CI-20231117-065651                
NuGet\Install-Package Lingya.Pagination -Version 1.0.8-CI-20231117-065651                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lingya.Pagination" Version="1.0.8-CI-20231117-065651" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lingya.Pagination --version 1.0.8-CI-20231117-065651                
#r "nuget: Lingya.Pagination, 1.0.8-CI-20231117-065651"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lingya.Pagination as a Cake Addin
#addin nuget:?package=Lingya.Pagination&version=1.0.8-CI-20231117-065651&prerelease

// Install Lingya.Pagination as a Cake Tool
#tool nuget:?package=Lingya.Pagination&version=1.0.8-CI-20231117-065651&prerelease                

Lingya.Pagination

Build status

Data Pagination For EntityFrameworkCore

#安装

PS> Install-Package  Lingya.Pagination

WebApi 使用方法

1. 基本用法

1.1 异步用法

[HttpGet()]
[ProducesResponseType(statusCode: 200, type: typeof(PageResult<Use>))]
public async Task<IActionResult> Index([FromQuery] PageParameter paramete = null) {
    var query = context.Users;
    return Ok(await query.ToPagingAsync(paramete));
}

1.2 searchKey 查询

[HttpGet()]
[ProducesResponseType(statusCode: 200, type: typeof(PageResult<Use>))]
public async Task<ActionResult<PageResult<User>>> Index([FromQuery] PageParameter paramete = null) {
  return await context.Users.AsQueryable ()
              .PagingBuilder (parameter)
              .Search (opt => opt.ContainsFor (u => u.FullName, u => u.UserName))
              .ToPagingAsync ();
}

1.3 聚合方法

生成 分页结果时同时生成 聚合结果

[HttpGet()]
[ProducesResponseType(statusCode: 200, type: typeof(PageResult<Account,Summary>))]
public async Task<IActionResult> Index([FromQuery] PageParameter paramete = null) {
  return await context.Account.AsNoTracking()
              .PagingBuilder (parameter)
              .WithAggregateAsync (g => new Summary(){
                Count = g.Count (),
                Quantity = g.Sum (a => a.Quantity),
                Price = g.Sum (a => a.Price)
            });
}

1.3 Sort 排序

支持 多列 单顺序排序

var param = new PageParameter();
param.SortBy = "Col1,Col2";
param.Descending = true;
return await query.ToPagingAsync(param);

1.4 同步方法

同步方法支持普通集合,如 IEnumerable<T> 的分页

2. 返回格式

ToPagingAsync 扩展方法返回一个包含泛型集合的 分页结果,包括 page对象和values集合,

{
  "page": {
    "total": 0, //总记录数量
    "pages": 0, //总页数
    "pageSize": 0, //页面大小
    "page": 0   //页号,从 1 开始计数
  },
  "values": [
    {
      "uid": "string",
      "userName": "string",
      "email": "string"
    }
  ]
}

4. 分页参数 PageParameter

  • PageSize 页面大小,默认20
  • Page 当前页码,默认为 1
  • SearchKey 搜索字符串,默认 null
  • SortBy 排序字段名
  • Descending 逆序排序
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8-CI-20231117-065651 229 11/17/2023
1.0.8-CI-20211218 220 12/17/2021
1.0.8-CI-20211217 165 12/17/2021
1.0.7 1,733 12/16/2021
1.0.6 767 6/15/2020
1.0.5 481 6/4/2020
1.0.4 680 8/11/2019
1.0.3 573 4/26/2019
1.0.2 725 12/22/2018
1.0.1 1,322 12/5/2018

# Changes in 1.0.8
     - support muti Order include owned property,like Order.Address.City

     # Changes in 1.0.7:
     - Use Search Method for string searchKey
     - add WithAggregate method support PageSult with custom Aggregate data
     ```c#
     await context.Account.AsNoTracking()
     .PagingBuilder (parameter)
     .WithAggregateAsync (g => new Summary(){
     Count = g.Count (),
     Quantity = g.Sum (a => a.Quantity),
     Price = g.Sum (a => a.Price)
     });
     ```

     # Changes in 1.0.6:
     - Add PagingQueryBuilder for auto process searchKey,support contains/startsWith/endsWith
     methods
     ```c#
     return await context.WeatherForecasts
     .PagingBuilder (parameter)
     .StartsFor (w => w.Summary)
     .ToPagingAsync ();
     ```
     - support Microsoft.EntityFrameworkCore 3.1.*