RsqlParserNet.AspNetCore 1.0.0

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

RsqlParserNet

CI Release Publish NuGet Publish GitHub Packages License .NET Coverage

Package Latest Release Downloads
RsqlParserNet RsqlParserNet NuGet RsqlParserNet Downloads
RsqlParserNet.Linq RsqlParserNet.Linq NuGet RsqlParserNet.Linq Downloads
RsqlParserNet.AspNetCore RsqlParserNet.AspNetCore NuGet RsqlParserNet.AspNetCore Downloads
RsqlParserNet.EntityFrameworkCore RsqlParserNet.EntityFrameworkCore NuGet RsqlParserNet.EntityFrameworkCore Downloads
RsqlParserNet.FastEndpoints RsqlParserNet.FastEndpoints NuGet RsqlParserNet.FastEndpoints Downloads
RsqlParserNet.OpenApi RsqlParserNet.OpenApi NuGet RsqlParserNet.OpenApi Downloads
RsqlParserNet.Swashbuckle RsqlParserNet.Swashbuckle NuGet RsqlParserNet.Swashbuckle Downloads
RsqlParserNet.NSwag RsqlParserNet.NSwag NuGet RsqlParserNet.NSwag Downloads

A dependency-light .NET parser for RSQL/FIQL-style REST API query expressions.

RsqlParserNet parses query text into a typed AST with source spans and structured diagnostics. The core package does not depend on ASP.NET Core, LINQ, Entity Framework Core, or ORM APIs.

Current status: 1.0.0 is the first stable release for the aligned package family.

Installation

Choose the smallest package that owns the behavior you need:

Package Use it when
RsqlParserNet You only need parsing, diagnostics, and the typed AST.
RsqlParserNet.Linq You want allowlisted expression tree predicates for IQueryable<T> or IEnumerable<T>.
RsqlParserNet.AspNetCore You want bindable query-string models for filter, sort, page, and pageSize.
RsqlParserNet.EntityFrameworkCore You want EF Core async paging helpers over already-composed queries.
RsqlParserNet.FastEndpoints You want FastEndpoints binding and validation failure glue.
RsqlParserNet.OpenApi You want ASP.NET Core built-in OpenAPI query parameter documentation.
RsqlParserNet.Swashbuckle You want Swashbuckle operation filters.
RsqlParserNet.NSwag You want NSwag operation processors.

Selectors are parsed as text. They are not reflected onto entity properties by the core package. Application code and adapters should explicitly allowlist the selectors they accept.

Core parser:

dotnet add package RsqlParserNet

LINQ adapter:

dotnet add package RsqlParserNet.Linq

ASP.NET Core binding:

dotnet add package RsqlParserNet.AspNetCore

Entity Framework Core helpers:

dotnet add package RsqlParserNet.EntityFrameworkCore

FastEndpoints helpers:

dotnet add package RsqlParserNet.FastEndpoints

RsqlParserNet.FastEndpoints currently requires FastEndpoints 7.0.1 or newer. Applications on older FastEndpoints versions can still use the ASP.NET Core query models directly through RsqlQueryRequest.Parse(...).

OpenAPI helpers:

dotnet add package RsqlParserNet.OpenApi

Swashbuckle helpers:

dotnet add package RsqlParserNet.Swashbuckle

NSwag helpers:

dotnet add package RsqlParserNet.NSwag

For local development, reference the project directly:

<ProjectReference Include="src/RsqlParserNet/RsqlParserNet.csproj" />
<ProjectReference Include="src/RsqlParserNet.Linq/RsqlParserNet.Linq.csproj" />
<ProjectReference Include="src/RsqlParserNet.AspNetCore/RsqlParserNet.AspNetCore.csproj" />
<ProjectReference Include="src/RsqlParserNet.EntityFrameworkCore/RsqlParserNet.EntityFrameworkCore.csproj" />
<ProjectReference Include="src/RsqlParserNet.FastEndpoints/RsqlParserNet.FastEndpoints.csproj" />
<ProjectReference Include="src/RsqlParserNet.OpenApi/RsqlParserNet.OpenApi.csproj" />
<ProjectReference Include="src/RsqlParserNet.Swashbuckle/RsqlParserNet.Swashbuckle.csproj" />
<ProjectReference Include="src/RsqlParserNet.NSwag/RsqlParserNet.NSwag.csproj" />

Quick Start

using RsqlParserNet;

var query = RsqlParser.Parse("""status=="active";title=="Bike*"""");

foreach (var comparison in query.Root.Comparisons())
{
    Console.WriteLine($"{comparison.Selector} {comparison.Operator} {comparison.Values[0].Text}");
}

For non-exception flows, use TryParse:

var result = RsqlParser.TryParse("status==");

if (!result.Success)
{
    foreach (var diagnostic in result.Diagnostics)
    {
        Console.WriteLine($"{diagnostic.Code}: {diagnostic.Message}");
    }
}

Supported Syntax

Common RSQL/FIQL forms are supported:

status==active
status=="active"
title=="SUP*"
status=in=(active,draft)
createdAt>=2026-01-01
status==active;title=="SUP*"
status==active,title=="Bike*"
(status==active;title=="SUP*"),status==draft

Logical operators:

; = AND
, = OR

AND has higher precedence than OR. Parentheses can override precedence.

See docs/syntax.md for the full grammar, selector rules, value behavior, custom operators, and wildcard/date semantics.

Options

Parser behavior can be configured:

var options = RsqlParseOptions.Default with
{
    AllowWordLogicalOperators = false,
    AllowDottedSelectors = true,
    CustomOperators =
    [
        new RsqlCustomOperator("=contains="),
        new RsqlCustomOperator("=all=", RequiresMultipleValues: true)
    ]
};

var result = RsqlParser.TryParse("title=contains=Bike", options);

Custom operators must use FIQL-style syntax such as =contains=, must not duplicate built-in operators, and must not be configured more than once.

Diagnostics

Parse errors are returned as structured diagnostics:

var result = RsqlParser.TryParse("status==");
var diagnostic = result.Diagnostics[0];

Console.WriteLine(diagnostic.Code);
Console.WriteLine(diagnostic.Message);
Console.WriteLine(diagnostic.Span.Start);
Console.WriteLine(diagnostic.Start.Line);
Console.WriteLine(diagnostic.Start.Column);

Current diagnostic codes:

Code Meaning
RSQL000 Empty expression
RSQL001 Invalid token or unterminated quoted string
RSQL002 Unexpected token or missing syntax
RSQL003 Invalid selector

RsqlParser.Parse throws ArgumentException for empty input and RsqlParseException for invalid syntax. RsqlParseException.Diagnostics contains the same structured diagnostics returned by TryParse.

For API responses, diagnostics can be projected without depending on any ASP.NET Core adapter:

var result = RsqlParser.TryParse(filter);

if (!result.Success)
{
    var errors = result.Diagnostics.Select(diagnostic => new
    {
        diagnostic.Code,
        diagnostic.Message,
        diagnostic.Start.Line,
        diagnostic.Start.Column
    });

    return Results.BadRequest(errors);
}

Core AST Model

The core parser returns a typed AST and does not assign query semantics to application fields:

Type Key properties Meaning
RsqlQuery Expression, Root Parsed query text and root AST node.
RsqlComparisonNode Selector, Operator, OperatorText, Values A selector/operator/value comparison such as status==active.
RsqlLogicalNode Operator, Children An AND/OR group. ; maps to AND and , maps to OR.
RsqlValue Text, RawText, Kind, Span Parsed value text, original source text, classified value kind, and source span.
RsqlDiagnostic Code, Message, Span, Start, End Structured parse error with source location.

Use RsqlNodeExtensions.Comparisons() when you only need to inspect every comparison node:

var query = RsqlParser.Parse("status==active;title==Bike");

foreach (var comparison in query.Root.Comparisons())
{
    Console.WriteLine($"{comparison.Selector}: {comparison.Values[0].Text}");
}

Manual AST Filtering

Use the core package directly when an endpoint supports a small, controlled subset and does not need RsqlParserNet.Linq.

This example supports only:

  • AND groups
  • ==
  • exactly one value
  • explicitly allowlisted selectors
using RsqlParserNet;

static IQueryable<Product> ApplyProductFilter(IQueryable<Product> query, RsqlNode node)
{
    return node switch
    {
        RsqlComparisonNode comparison => ApplyProductComparison(query, comparison),
        RsqlLogicalNode { Operator: RsqlLogicalOperator.And } logical =>
            logical.Children.Aggregate(query, ApplyProductFilter),
        RsqlLogicalNode { Operator: RsqlLogicalOperator.Or } =>
            throw new NotSupportedException("OR is not supported by this endpoint."),
        _ => throw new NotSupportedException("Unsupported RSQL node.")
    };
}

static IQueryable<Product> ApplyProductComparison(
    IQueryable<Product> query,
    RsqlComparisonNode comparison)
{
    if (comparison.Operator is not RsqlComparisonOperator.Equal)
    {
        throw new NotSupportedException("Only == is supported by this endpoint.");
    }

    if (comparison.Values.Count is not 1)
    {
        throw new NotSupportedException("Only one comparison value is supported.");
    }

    var value = comparison.Values[0].Text
        ?? throw new NotSupportedException("Null values are not supported by this endpoint.");

    return comparison.Selector switch
    {
        "status" => query.Where(product => product.Status == value),
        "title" => query.Where(product => product.Title == value),
        _ => throw new ArgumentException($"Unsupported filter field '{comparison.Selector}'.")
    };
}

Endpoint code can parse first, return syntax diagnostics, and then apply the allowlisted subset:

var result = RsqlParser.TryParse(filter);

if (!result.Success)
{
    return Results.BadRequest(result.Diagnostics.Select(diagnostic => new
    {
        diagnostic.Code,
        diagnostic.Message,
        diagnostic.Start.Line,
        diagnostic.Start.Column
    }));
}

var products = ApplyProductFilter(db.Products, result.Query!.Root);

LINQ Adapter

The repository includes an early RsqlParserNet.Linq adapter project. It translates parsed AST nodes into expression tree predicates using explicit selector mappings:

using RsqlParserNet;
using RsqlParserNet.Linq;

var query = RsqlParser.Parse("status=in=(active,draft);count>=10");

var filtered = products.ApplyRsql(query, options =>
{
    options.Allow("status", x => x.Status);
    options.Allow("count", x => x.Count);
});

You can also build the predicate separately when another layer should decide how to compose or apply it:

var predicate = RsqlPredicateBuilder.BuildPredicate<Product>("status==active", options =>
{
    options.Allow("status", x => x.Status);
});

var filtered = products.Where(predicate);

For repeated endpoint/query contracts, put mappings in a reusable profile:

public sealed class ProductRsqlProfile : RsqlLinqProfile<Product>
{
    public override RsqlParseOptions ConfigureParseOptions(RsqlParseOptions options)
    {
        return options.WithLinqOperators();
    }

    public override void Configure(RsqlLinqOptions<Product> options)
    {
        options.Allow("name", x => x.Name);
        options.Allow("status", x => x.Status);
        options.Allow("count", x => x.Count);
        options.Allow("tags", x => x.Tags);
        options.AllowStringContainsOperator();
        options.AllowStringStartsWithOperator();
        options.AllowStringEndsWithOperator();
        options.AllowCollectionAnyOperator();
        options.AllowCollectionAllOperator();
    }
}

var filtered = products.ApplyRsql("status==active;name=contains=ik", new ProductRsqlProfile());

The adapter currently supports:

Operator LINQ behavior
== / != Equality and inequality
> / >= / < / <= Comparable mapped types such as numbers and dates
=in= / =out= Membership checks over the supplied value list
=contains= / =starts= / =ends= Custom string helpers for allowlisted string fields
=any= / =all= Custom collection helpers for allowlisted collection fields
; / , AndAlso and OrElse expression composition

Values are converted using the mapped member type, including common scalar types, enums, Guid, DateTime, DateTimeOffset, DateOnly, and TimeOnly.

String helper operators and wildcard equality use the LINQ provider's string comparison behavior by default. APIs can opt into endpoint-wide case-insensitive string matching through RsqlLinqOptions<T>.StringComparisonMode.

Custom operators can be translated explicitly after they are configured in parser options:

var parseOptions = RsqlParseOptions.Default with
{
    CustomOperators = [new RsqlCustomOperator(RsqlLinqOperators.Contains)]
};

var filtered = products.ApplyRsql("name=contains=ik", options =>
{
    options.Allow("name", x => x.Name);
    options.AllowStringContainsOperator();
}, parseOptions);

Collection fields can use explicit custom operators:

tags=any=(bike,outdoor)
tags=all=(bike,outdoor)

String equality supports common * wildcards by default:

name==B*    -> StartsWith("B")
name==*met  -> EndsWith("met")
name==*ik*  -> Contains("ik")
name==Bo*d  -> StartsWith("Bo") && EndsWith("d")

See docs/linq-adapter.md for wildcard behavior, value conversion, and adapter limitations. See docs/aspnet-core-usage.md for ASP.NET Core request handling examples.

ASP.NET Core Binding

RsqlParserNet.AspNetCore adds bindable query wrappers for request query strings. Minimal APIs can accept RsqlQueryRequest directly to reuse parsed filter, sort, and page state:

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) =>
{
    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);

    return Results.Ok(result);
});

Adapter Direction

Expression trees are a good fit for LINQ and Entity Framework Core integration, but they belong in separate adapter packages rather than the parser core.

The intended adapter shape is explicit and allowlisted:

query.ApplyRsql(filter, options =>
{
    options.Allow("title", x => x.Title);
    options.Allow("status", x => x.Status);
    options.Allow("createdAt", x => x.CreatedAt);
});

The core parser should not expose arbitrary reflected entity/property access. Future adapters should translate the AST into expression trees only through configured field mappings.

Framework adapters should stay separate when they need framework-specific dependencies. RsqlParserNet.AspNetCore owns ASP.NET Core binding helpers.

RsqlParserNet.EntityFrameworkCore owns EF Core async execution helpers, including paged result helpers that return items and pagination metadata. Sorting uses the same allowlisted profile mappings as filtering with sort=field, sort=-field, and multi-field sort text such as sort=-createdAt,name.

RsqlParserNet.FastEndpoints owns FastEndpoints-specific validation glue. It reuses the ASP.NET Core query models and adds ValidationFailure entries to the endpoint, so FastEndpoints APIs can keep their normal validation response flow.

RsqlParserNet.OpenApi owns endpoint-scoped OpenAPI query parameter documentation helpers for filter, sort, page, and pageSize.

RsqlParserNet.Swashbuckle owns Swashbuckle operation filters for documenting the same query parameters through SwaggerGen.

RsqlParserNet.NSwag owns NSwag operation processors for documenting the same query parameters through NSwag and FastEndpoints.Swagger-style OpenAPI generation.

Development

dotnet build RsqlParserNet.sln
dotnet test RsqlParserNet.sln
dotnet test RsqlParserNet.sln --collect:"XPlat Code Coverage"
dotnet pack src/RsqlParserNet/RsqlParserNet.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.Linq/RsqlParserNet.Linq.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.AspNetCore/RsqlParserNet.AspNetCore.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.EntityFrameworkCore/RsqlParserNet.EntityFrameworkCore.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.FastEndpoints/RsqlParserNet.FastEndpoints.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.OpenApi/RsqlParserNet.OpenApi.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.Swashbuckle/RsqlParserNet.Swashbuckle.csproj --configuration Release --output artifacts/packages
dotnet pack src/RsqlParserNet.NSwag/RsqlParserNet.NSwag.csproj --configuration Release --output artifacts/packages

Coverage is collected locally with Coverlet. A public percentage badge will be added after coverage publishing is wired into CI.

Release Automation

Pushing a v* tag builds, tests, packs, and creates a GitHub Release with every package artifact. Tags also publish all generated .nupkg and .snupkg files to NuGet.org when the repository secret NUGET_API_KEY is configured.

The manual Publish NuGet workflow remains available for retrying one package from a release tag.

Project Notes

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.0 135 5/10/2026
0.3.0-preview.1 91 5/6/2026
0.2.0-preview.1 128 5/5/2026
0.1.0-preview.1 54 5/5/2026

First stable release of the ASP.NET Core adapter with bindable filter, multi-field sort, page, combined query request, and structured query error helpers.