TailoredApps.Shared.MediatR.PagedRequest
2.1.0
See the version list below for details.
dotnet add package TailoredApps.Shared.MediatR.PagedRequest --version 2.1.0
NuGet\Install-Package TailoredApps.Shared.MediatR.PagedRequest -Version 2.1.0
<PackageReference Include="TailoredApps.Shared.MediatR.PagedRequest" Version="2.1.0" />
<PackageVersion Include="TailoredApps.Shared.MediatR.PagedRequest" Version="2.1.0" />
<PackageReference Include="TailoredApps.Shared.MediatR.PagedRequest" />
paket add TailoredApps.Shared.MediatR.PagedRequest --version 2.1.0
#r "nuget: TailoredApps.Shared.MediatR.PagedRequest, 2.1.0"
#:package TailoredApps.Shared.MediatR.PagedRequest@2.1.0
#addin nuget:?package=TailoredApps.Shared.MediatR.PagedRequest&version=2.1.0
#tool nuget:?package=TailoredApps.Shared.MediatR.PagedRequest&version=2.1.0
TailoredApps.Shared.MediatR.PagedRequest
PagedAndSortedRequest<TResponse, TQuery, TModel>: a base class for MediatR requests that return one page of a
list. It carries the page, the page size, the sort field and direction and a filter object, so every list
request in an application has the same shape. The contracts it implements come from TailoredApps.Shared.Querying.
Installation
dotnet add package TailoredApps.Shared.MediatR.PagedRequest
Registration
Nothing to register: the package has no dependency-injection extension. Requests derived from the base class
are ordinary MediatR requests (IRequest<TResponse>).
Usage
The handler below uses the paging and sorting extensions of TailoredApps.Shared.EntityFramework, which accept
the request directly and validate what the client sent.
using TailoredApps.Shared.EntityFramework.Querying;
using TailoredApps.Shared.MediatR.PagedRequest;
using TailoredApps.Shared.Querying;
public class ProductFilter : QueryBase
{
public string? NameContains { get; set; }
}
public class GetProducts : PagedAndSortedRequest<PagedResult<ProductDto>, ProductFilter, ProductDto>
{
}
public class GetProductsHandler(ShopDbContext db) : IRequestHandler<GetProducts, PagedResult<ProductDto>>
{
public async Task<PagedResult<ProductDto>> Handle(GetProducts request, CancellationToken cancellationToken)
{
IQueryable<Product> products = db.Products;
var name = request.Filter?.NameContains;
if (!string.IsNullOrWhiteSpace(name))
{
products = products.Where(p => p.Name.Contains(name));
}
var page = await products
.ApplySorting(request, ["Name", "Price"]) // allow-list of sort fields
.PagingAsync(request);
return page.Project(p => new ProductDto(p.Id, p.Name, p.Price));
}
}
| Member | Meaning |
|---|---|
Page, Count |
Page number (1-based) and page size; null means no paging |
IsPagingSpecified |
true when both Page and Count have a value |
SortField, SortDir |
Field to sort by and SortDirection (Asc, Desc) |
IsSortingSpecified |
true when SortField is not blank and SortDir has a value |
Filter |
The filter object, a class derived from QueryBase |
IsSortBy(fieldName) |
Compares SortField with a field name, ignoring case |
Good to know
TQuerymust derive fromQueryBaseandTResponsemust implementIPagedResult<TModel>.- The class only carries the values.
Page,CountandSortFieldusually come straight from the HTTP request and are not checked here: a handler that callsSkip/Takeitself has to limit the page size. PagingAsyncandApplySortinginTailoredApps.Shared.EntityFrameworkdo check them: the page must be at least 1, the page size between 1 andPagingQuery<T>.MaxPageSize(1000 by default), and the sort field a single property name, optionally from an allow-list. Violations throwArgumentOutOfRangeExceptionorArgumentException.IsSortingSpecifiedis alsotrueforSortDirection.Undefined.
Documentation
https://shared.tailoredapps.pl/en/Libraries/MediatR/PagedRequest/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- MediatR (>= 12.5.0)
- TailoredApps.Shared.Querying (>= 2.1.0)
-
net11.0
- MediatR (>= 12.5.0)
- TailoredApps.Shared.Querying (>= 2.1.0)
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 |
|---|---|---|
| 3.0.0-preview.2 | 51 | 11/12/2026 |
| 3.0.0-preview.1 | 56 | 11/12/2026 |
| 2.1.0 | 93 | 11/12/2026 |
| 2.0.1 | 89 | 11/12/2026 |
| 2.0.0 | 101 | 11/12/2026 |
| 1.6.0 | 89 | 11/12/2026 |
| 1.4.19 | 423 | 10/26/2026 |
| 1.4.18 | 522 | 10/23/2026 |
| 1.4.17 | 731 | 10/6/2026 |
| 1.4.16 | 118 | 9/28/2026 |
| 1.4.15 | 123 | 9/21/2026 |
| 1.4.14 | 122 | 8/20/2026 |
| 1.4.13 | 127 | 8/20/2026 |
| 1.4.12 | 146 | 8/20/2026 |
| 1.4.11 | 140 | 8/7/2026 |
| 1.4.10 | 249 | 7/8/2026 |
| 1.4.9 | 152 | 7/8/2026 |
| 1.4.8 | 148 | 7/6/2026 |
| 1.4.7 | 151 | 5/20/2026 |
| 1.4.6 | 150 | 5/20/2026 |