RsqlParserNet.AspNetCore 1.0.3

dotnet add package RsqlParserNet.AspNetCore --version 1.0.3
                    
NuGet\Install-Package RsqlParserNet.AspNetCore -Version 1.0.3
                    
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="RsqlParserNet.AspNetCore" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RsqlParserNet.AspNetCore" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="RsqlParserNet.AspNetCore" />
                    
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 RsqlParserNet.AspNetCore --version 1.0.3
                    
#r "nuget: RsqlParserNet.AspNetCore, 1.0.3"
                    
#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 RsqlParserNet.AspNetCore@1.0.3
                    
#: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=RsqlParserNet.AspNetCore&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=RsqlParserNet.AspNetCore&version=1.0.3
                    
Install as a Cake Tool

RsqlParserNet.AspNetCore

RsqlParserNet.AspNetCore NuGet RsqlParserNet.AspNetCore Downloads

Bindable ASP.NET Core query-string models for filter, sort, page, and pageSize, plus validation-error projection. Minimal APIs accept RsqlQueryRequest directly to reuse parsed filter, sort, and page state.

Part of the RsqlParserNet family. It builds on RsqlParserNet (parsing, diagnostics, the typed AST) and RsqlParserNet.Linq (allowlisted filter/sort translation and pagination models). RsqlParserNet.FastEndpoints builds on this package to add FastEndpoints validation glue.

Installation

dotnet add package RsqlParserNet.AspNetCore

Quick start

Register binding options once, then bind RsqlQueryRequest in a minimal API endpoint. Async paging via ToRsqlPageAsync comes from RsqlParserNet.EntityFrameworkCore.

using Microsoft.EntityFrameworkCore;
using RsqlParserNet;
using RsqlParserNet.AspNetCore;
using RsqlParserNet.EntityFrameworkCore;
using RsqlParserNet.Linq;

builder.Services.AddRsqlQueryRequest(
    configureFilter: options =>
    {
        options.ParseOptions = ProductRsqlProfile.Instance.ConfigureParseOptions(RsqlParseOptions.Default);
    },
    configurePage: options => options.MaxPageSize = 100);

app.MapGet("/products", async (
    RsqlQueryRequest request,
    AppDbContext db,
    CancellationToken cancellationToken) =>
{
    if (!request.IsValid)
    {
        return Results.ValidationProblem(request.ToValidationErrors());
    }

    if (!request.TryApplyTo(db.Products, ProductRsqlProfile.Instance, out var query, out var errors))
    {
        return Results.ValidationProblem(request.ToValidationErrors(errors));
    }

    query = request.Sort.HasRequest
        ? query
        : query.OrderBy(product => product.Id);

    var result = await query.ToRsqlPageAsync(request.PageRequest, cancellationToken);

    return Results.Ok(result);
});

The default query contract is:

GET /products?filter=status==active&sort=-createdAt&page=1&pageSize=25

Invalid filter, sort, page, or page size values do not fail binding. The bound request becomes invalid (IsValid is false), and the endpoint decides how to return the error.

TryApplyTo is the safest endpoint path when query semantics depend on a LINQ profile. It catches adapter translation errors such as unknown selectors, unsupported operators, or value conversion failures and returns them through the same structured error model.

Query models

Type Purpose
RsqlQueryRequest Combined filter, sort, and page state bound from the request. Exposes IsValid, Filter, Sort, Page, PageRequest, ApplyTo, TryApplyTo, and the error/validation helpers.
RsqlQueryFilter The bound RSQL filter (filter by default). Exposes IsValid, HasQuery, Query, Diagnostics, and a static Parse for non-minimal-API frameworks.
RsqlSortQuery The bound sort request (sort by default). Exposes HasRequest, Requests, and IsValid.
RsqlPageQuery The bound page state (page and pageSize by default), with default and maximum page-size clamping. Exposes IsValid and Request.

Bind a single component directly when an endpoint only needs part of the contract. Use the static RsqlQueryFilter.Parse(...) when a framework does not use minimal API parameter binding:

var parseOptions = ProductRsqlProfile.Instance.ConfigureParseOptions(RsqlParseOptions.Default);
var filter = RsqlQueryFilter.Parse(httpContext.Request.Query["filter"].FirstOrDefault(), parseOptions);

if (filter.IsValid && filter.HasQuery)
{
    query = query.ApplyRsql(filter.Query!, ProductRsqlProfile.Instance);
}

Register binding options with AddRsqlQueryRequest (filter, sort, and page together) or with AddRsqlQueryFilter, AddRsqlSortQuery, and AddRsqlPageQuery individually.

Validation errors

GetErrors() returns structured RsqlQueryError values for custom API error shapes. Each error carries:

Field Meaning
ParameterName The query string parameter that produced the error.
Message The human-readable error message.
Source The originating component: RsqlQueryErrorSource.Filter, .Sort, or .Page.
Code An optional stable diagnostic code.
Span, Start, End Optional parser source span and locations for filter diagnostics.

To return responses through the ASP.NET Core validation pipeline:

// Dictionary<string, string[]> keyed by query parameter name.
return Results.ValidationProblem(request.ToValidationErrors());

// Or the same errors as HttpValidationProblemDetails (filter/translation errors also
// surfaced under the "rsqlErrors" extension).
return Results.Problem(request.ToValidationProblemDetails());

Both ToValidationErrors() and ToValidationProblemDetails() have overloads that accept an IReadOnlyList<RsqlQueryError>, so adapter translation errors from TryApplyTo flow through the same projection. Filter diagnostics keep the parser diagnostic code (for example RSQL002) in each message.

Error codes:

Code Meaning
RSQL000RSQL003 Filter parse diagnostics from RsqlParserNet (empty expression, invalid token, unexpected token, invalid selector).
RsqlQueryErrorCodes.AdapterTranslationError (RSQL100) A parsed query could not be translated with the configured LINQ profile.

Documentation

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

NuGet packages (2)

Showing the top 2 NuGet packages that depend on RsqlParserNet.AspNetCore:

Package Downloads
RsqlParserNet.OpenApi

OpenAPI query parameter documentation helpers for RsqlParserNet API endpoints.

RsqlParserNet.FastEndpoints

FastEndpoints validation and request helpers for RsqlParserNet query binding.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 193 6/16/2026
1.0.2 190 5/23/2026
1.0.1 143 5/18/2026
1.0.0 194 5/10/2026
0.3.0-preview.1 138 5/6/2026
0.2.0-preview.1 138 5/5/2026
0.1.0-preview.1 59 5/5/2026

Maintenance release aligning the RsqlParserNet package family at 1.0.3 and adding a dedicated package README.