Fluens.Cqrs 0.6.6

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

Fluens.Cqrs

CQRS pattern implementation with command/query dispatchers, handler interfaces, and logging/tracing decorators.

Installation

dotnet add package Fluens.Cqrs

Usage

Registration

fluensBuilder
    .AddCqrs()
    .AddCqrsHandlers<Program>()
    .AddCqrsLoggingDecorator()
    .AddCqrsTracingDecorator();

Commands

// Command without return value
public record CreateOrder(string Number) : ICommand;

public class CreateOrderHandler : ICommandHandler<CreateOrder>
{
    public async Task<Result> HandleAsync(CreateOrder command, CancellationToken cancellationToken)
    {
        // ...
        return Result.Success();
    }
}

// Command with return value
public record GetOrder(int Id) : ICommand<OrderDto>;

public class GetOrderHandler : ICommandHandler<GetOrder, OrderDto>
{
    public async Task<Result<OrderDto>> HandleAsync(GetOrder command, CancellationToken cancellationToken)
    {
        // ...
        return Result.Success(new OrderDto());
    }
}

Paginated Queries

public record SearchOrders(string? Term) : PagedQuery<PagedResult<OrderDto>>;

PagedQuery<TResult> provides default pagination properties with [JsonPropertyName] short codes to minimize JSON payload:

Property Short code Default
PageIndex pi 1
PageSize ps 20
SortOrder so null
SortProperty sp null

Subclasses automatically inherit the short names in any JsonSerializerContext — no extra configuration required. Pagination constants are available via Constants.Cqrs.Query (DefaultPageIndex, DefaultPageSize, MinPageSize, MaxPageSize).

Queries

public record SearchOrders(string? Term) : IQuery<IReadOnlyList<OrderDto>>;

public class SearchOrdersHandler : IQueryHandler<SearchOrders, IReadOnlyList<OrderDto>>
{
    public async Task<IReadOnlyList<OrderDto>> HandleAsync(SearchOrders query, CancellationToken cancellationToken)
    {
        // Queries return the result directly (no Result wrapper)
        return [];
    }
}

Module-Level Registration

// In IModuleSetup.RegisterServices:
module.AddHandlers(); // scans module assembly, validates assembly boundaries

AddHandlers() scans the module assembly for handler implementations, registers them with scoped lifetime, and enforces module boundary rules: handlers can only handle commands/queries defined in the same module assembly, and cross-module dispatch at runtime throws InvalidOperationException.

Dispatching

// Inject ICommandDispatcher / IQueryDispatcher
Result result = await commandDispatcher.SendAsync(new CreateOrder("ORD-001"), ct);
IReadOnlyList<OrderDto> orders = await queryDispatcher.SendAsync(new SearchOrders("test"), ct);

Built-in decorators: LoggingCommandHandlerDecorator (logs execution), TracingCommandHandlerDecorator (OpenTelemetry activity).

License

This project is licensed under the MIT License.

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

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
0.6.6 43 3/11/2026
0.6.5 82 3/4/2026
0.6.4 82 3/4/2026
0.6.3 85 3/3/2026
0.6.2 88 3/2/2026
0.6.1 80 3/2/2026
0.6.0 82 3/1/2026
0.5.7 84 3/1/2026
0.5.6 80 3/1/2026
0.5.5 82 2/28/2026
0.5.4 84 2/28/2026
0.5.3 89 2/27/2026
0.5.2 88 2/27/2026
0.5.1 86 2/27/2026
0.5.0 87 2/26/2026
0.3.2 85 2/26/2026
0.3.1 86 2/26/2026
0.3.0 83 2/24/2026
0.2.5 91 2/24/2026
0.2.4 87 2/24/2026
Loading failed