Fluens.Cqrs
0.6.6
dotnet add package Fluens.Cqrs --version 0.6.6
NuGet\Install-Package Fluens.Cqrs -Version 0.6.6
<PackageReference Include="Fluens.Cqrs" Version="0.6.6" />
<PackageVersion Include="Fluens.Cqrs" Version="0.6.6" />
<PackageReference Include="Fluens.Cqrs" />
paket add Fluens.Cqrs --version 0.6.6
#r "nuget: Fluens.Cqrs, 0.6.6"
#:package Fluens.Cqrs@0.6.6
#addin nuget:?package=Fluens.Cqrs&version=0.6.6
#tool nuget:?package=Fluens.Cqrs&version=0.6.6
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 | Versions 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. |
-
net10.0
- Fluens (>= 0.6.6)
- Fluens.Kernel (>= 0.6.6)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.3)
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 |