B9_Pagination 1.0.2
See the version list below for details.
dotnet add package B9_Pagination --version 1.0.2
NuGet\Install-Package B9_Pagination -Version 1.0.2
<PackageReference Include="B9_Pagination" Version="1.0.2" />
paket add B9_Pagination --version 1.0.2
#r "nuget: B9_Pagination, 1.0.2"
// Install B9_Pagination as a Cake Addin #addin nuget:?package=B9_Pagination&version=1.0.2 // Install B9_Pagination as a Cake Tool #tool nuget:?package=B9_Pagination&version=1.0.2
B9_Pagination
Extensions for simple pagination
How to use?
You can use PaginationQuery model for set pagination parameter
var pagination = new PaginationQuery(pageNumber: 1, pageSize: 10);
var paginationResult = await items
.Where(x => x.Id > 10)
.GetPaginationAsync(pagination);
or set directly in method
var paginationResult = await items
.Where(x => x.Id > 10)
.GetPaginationAsync(pageNumber: 1, pageSize: 10);
Check out the sample project
You can use pagination in API endpoints
[HttpGet]
[ProducesResponseType(typeof(IPagination<GetShortAccountDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetClientAccounts(
[FromQuery] PaginationQuery pagination = default,
[FromQuery] FilterDto filter = default,
UserEnums.SortBy? sortBy = default,
CancellationToken cancellationToken = default)
=> (await _accountService.GetAccountsAsync(pagination, filter, sortBy, cancellationToken)).ToActionResult();
What if you need to do something(Select,Where,GroupBy,etc) with the data before doing pagination?
You can use Pager<T>
and manage validation yourself
var mappedItems = items
.GroupBy(dto => dto.Name)
.Select(g => new UserDto
{
Name = g.Key,
Contacts = g.Select(dto => new UserContactDto
{
Email = dto.Email,
Count = dto.Count
})
})
.ToList();
var totalCount = mappedItems.Count();
var pager = new Pager<UserDto>(totalCount, pagination.PageNumber, pagination.PageSize);
if (!pager.IsValidPage)
return pager.GetEmptyPagination();
return pager.GetPagination(mappedItems);
Additionaly if you need just map type you can use extension methods for map with AutoMapper
GetPaginationWithMapAsync(this IQueryable<object> items, PaginationQuery pagination, IMapper mapper, CancellationToken cancellationToken = default)
or
GetPaginationWithMapAsync<TResult>(this IQueryable<object> items, PaginationQuery pagination, IConfigurationProvider configurationProvider, CancellationToken cancellationToken = default)
Product | Versions 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- AutoMapper (>= 10.1.1)
- Microsoft.EntityFrameworkCore (>= 5.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.