Lingya.Pagination 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Lingya.Pagination --version 1.0.4                
NuGet\Install-Package Lingya.Pagination -Version 1.0.4                
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.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lingya.Pagination --version 1.0.4                
#r "nuget: Lingya.Pagination, 1.0.4"                
#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.4

// Install Lingya.Pagination as a Cake Tool
#tool nuget:?package=Lingya.Pagination&version=1.0.4                

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<IActionResult> Index([FromQuery] PageParameter paramete = null) {
    if(paramete!=null || String.IsNullOrEmpty(paramete.SearchKey)){
      var query = context.Users.Where(u=>u.UserName.StartWith(parame.SearchKey));
      return Ok(await query.ToPagingAsync(paramete));
    }else{
      var query = context.Users;
      return Ok(await query.ToPagingAsync(paramete));
    }
}

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 was computed.  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 was computed. 
.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 234 11/17/2023
1.0.8-CI-20211218 222 12/17/2021
1.0.8-CI-20211217 167 12/17/2021
1.0.7 1,768 12/16/2021
1.0.6 773 6/15/2020
1.0.5 487 6/4/2020
1.0.4 686 8/11/2019
1.0.3 579 4/26/2019
1.0.2 732 12/22/2018
1.0.1 1,331 12/5/2018