QueryQuiver 1.1.0

dotnet add package QueryQuiver --version 1.1.0
NuGet\Install-Package QueryQuiver -Version 1.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="QueryQuiver" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QueryQuiver --version 1.1.0
#r "nuget: QueryQuiver, 1.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.
// Install QueryQuiver as a Cake Addin
#addin nuget:?package=QueryQuiver&version=1.1.0

// Install QueryQuiver as a Cake Tool
#tool nuget:?package=QueryQuiver&version=1.1.0

QueryQuiver

Simple way to add filtering, pagination and sorting to you API.

Instalation

You can instal QueryQuiver via NuGet

Install-Package QueryQuiver

Or via .NET CLI

dotnet add package QueryQuiver

Usage

QueryQuiver is using query params of API to filter out results. All you need to do is to pass query params to extension method ApplyFilters().

Implementation

[HttpGet]
public async Task<ActionResult<IEnumerable<Person>>> GetPeople([FromQuery] IDictionary<string, string[]> filters)
{
    return dbContext.People.ApplyFilters(filters).ToListAsync()
}

Request

Data are passed as query params in request. Name of properties in request has to match model excatly to work.
Format for filter is as follow:

{{propertyName}}={{filterOperator}}:{{value}}
rating=ge:4

Spaces

You can use spaces in values (use encoding in quqery params)

Case sensitivy

Both property names and values are case insensitve

Nested/Owned properties

job.title=eq:Miner

Pagination

Pagination requires two parameters
page (offset of results) - default 0
pageSize (number of results) - default 20
If parametr is not support default values are used

Sort

Currently only one sorting parametr is allowed
{{sort}}={{propertyName}}:{{desc/asc}}

Filter operators
Operation Query
Equal eq
NotEqual ne
GreaterThan gt
GreaterThanOrEqual ge
LessThan lt
LessThanOrEqual le
Contains ct
StartsWith sw
EndsWith ew
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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.1.0 95 7/2/2024
1.0.0 197 6/9/2024