TailoredApps.Shared.Querying 2.1.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package TailoredApps.Shared.Querying --version 2.1.0
                    
NuGet\Install-Package TailoredApps.Shared.Querying -Version 2.1.0
                    
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="TailoredApps.Shared.Querying" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TailoredApps.Shared.Querying" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="TailoredApps.Shared.Querying" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TailoredApps.Shared.Querying --version 2.1.0
                    
#r "nuget: TailoredApps.Shared.Querying, 2.1.0"
                    
#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.
#:package TailoredApps.Shared.Querying@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TailoredApps.Shared.Querying&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TailoredApps.Shared.Querying&version=2.1.0
                    
Install as a Cake Tool

TailoredApps.Shared.Querying

Contracts for list queries: a query with paging, sorting and a filter object, and a result with one page of items plus the total count. The package has no dependencies, so the same types can be used in an API contract, in a service and in the data layer. TailoredApps.Shared.EntityFramework and TailoredApps.Shared.MediatR.PagedRequest build on these contracts.

Installation

dotnet add package TailoredApps.Shared.Querying

Registration

Nothing to register: the package contains contracts only and has no dependency-injection extension.

Usage

using TailoredApps.Shared.Querying;

public class CustomerFilter : QueryBase
{
    public string? NameContains { get; set; }
}

public class CustomerQuery : PagedAndSortedQuery<CustomerFilter>
{
}

public class CustomerPage : IPagedResult<CustomerDto>
{
    public ICollection<CustomerDto> Results { get; set; } = new List<CustomerDto>();
    public int Count { get; set; }   // total number of matching items, not the size of the page
}

Applying a query (EF Core shown; maxPageSize is a limit you choose):

if (query.IsSortingSpecified && query.IsSortBy("Name"))
{
    customers = query.SortDir == SortDirection.Desc
        ? customers.OrderByDescending(c => c.Name)
        : customers.OrderBy(c => c.Name);
}

var total = await customers.CountAsync(cancellationToken);

if (query.IsPagingSpecified)
{
    var size = Math.Clamp(query.Count!.Value, 1, maxPageSize);
    customers = customers.Skip((Math.Max(query.Page!.Value, 1) - 1) * size).Take(size);
}
Type Purpose
QueryBase Abstract base class of filter objects
PagedAndSortedQuery<TQuery> Abstract query: Page, Count, SortField, SortDir, Filter, IsPagingSpecified, IsSortingSpecified, IsSortBy(fieldName)
IPagedAndSortedQuery<TQuery>, IQuery<T> The contract of the query and of its filter
IPagingParameters, ISortingParameters, IQueryParameters Read-only views of the paging values, the sorting values, and both
IPagedResult<T> Results (the page) and Count (the total)
IPagedAndSortedRequest<TResponse, TQuery, TModel> Query contract tied to a response type; implemented by MediatR.PagedRequest
SortDirection Undefined = 0, Asc = 1, Desc = 2
QueryMap<TDestination, TSource> A pair of expressions naming a field of a model and the matching field of an entity

Good to know

  • Page is 1-based. Page, Count and SortDir are nullable; IsPagingSpecified requires both Page and Count, IsSortingSpecified requires a non-blank SortField and a SortDir value.
  • IsSortingSpecified is also true for SortDirection.Undefined, the enum's zero value.
  • IsSortBy compares field names ignoring case.
  • Nothing here validates the values: a negative page, a huge page size or an arbitrary sort field pass through as given. Check them where the query is applied. The paging and sorting extensions of TailoredApps.Shared.EntityFramework do that for IPagingParameters and ISortingParameters.
  • QueryMap<TDestination, TSource> only holds the two expressions; nothing in this package interprets them.

Documentation

https://shared.tailoredapps.pl/en/Libraries/Querying/

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net11.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on TailoredApps.Shared.Querying:

Package Downloads
TailoredApps.Shared.EntityFramework

Package Description

TailoredApps.Shared.MediatR.PagedRequest

Package Description

TabloRazor.Table.WebApiDataProvider

Blazor Table WebApi Data Provider with usage of TailoredApps.Shared.Querying

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-preview.2 63 11/12/2026
3.0.0-preview.1 71 11/12/2026
2.1.0 121 11/12/2026
2.0.1 114 11/12/2026
2.0.0 133 11/12/2026
1.6.0 135 11/12/2026
1.4.19 554 10/26/2026
1.4.18 737 10/23/2026
1.4.17 1,073 10/6/2026
1.4.16 161 9/28/2026
1.4.15 169 9/21/2026
1.4.14 187 8/20/2026
1.4.13 187 8/20/2026
1.4.12 201 8/20/2026
1.4.11 189 8/7/2026
1.4.10 313 7/8/2026
1.4.9 201 7/8/2026
1.4.8 206 7/6/2026
1.4.7 215 5/20/2026
1.4.6 201 5/20/2026
Loading failed