Lingya.Pagination 1.0.1

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

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

Lingya.Pagination

Data Pagination For WebApi

#安装

PS> Install-Package  Lingya.Pagination

WebApi 使用方法

1. 基本用法

[HttpGet()]
[ProducesResponseType(statusCode: 200, type: typeof(PageResult<Use>))]
public async Task<IActionResult> Index([FromQuery] PageParamete paramete = null) {
    var query = context.Users;
    return Ok(await query.PagingAsync(paramete));
}
  1. searchKey 查询
[HttpGet()]
[ProducesResponseType(statusCode: 200, type: typeof(PageResult<Use>))]
public async Task<IActionResult> Index([FromQuery] PageParamete paramete = null) {
    if(paramete!=null || String.IsNullOrEmpty(paramete.SearchKey)){
      var query = context.Users.Where(u=>u.UserName.StartWith(parame.SearchKey));
      return Ok(await query.PagingAsync(paramete));
    }else{
      var query = context.Users;
      return Ok(await query.PagingAsync(paramete));
    }
}
  1. Sort 排序 ...

2. 返回格式

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

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

PageParamete

  • 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 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 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,732 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 571 4/26/2019
1.0.2 725 12/22/2018
1.0.1 1,322 12/5/2018