LenzEng.Utilities.Cqrs
0.2.0
dotnet add package LenzEng.Utilities.Cqrs --version 0.2.0
NuGet\Install-Package LenzEng.Utilities.Cqrs -Version 0.2.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="LenzEng.Utilities.Cqrs" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LenzEng.Utilities.Cqrs" Version="0.2.0" />
<PackageReference Include="LenzEng.Utilities.Cqrs" />
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 LenzEng.Utilities.Cqrs --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LenzEng.Utilities.Cqrs, 0.2.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 LenzEng.Utilities.Cqrs@0.2.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=LenzEng.Utilities.Cqrs&version=0.2.0
#tool nuget:?package=LenzEng.Utilities.Cqrs&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Toto.Utilities.Cqrs
Framework-agnostic CQRS dispatch infrastructure for .NET. Provides the core interfaces and processor implementations to wire command/query handling into any application without coupling to HTTP or ASP.NET Core.
What It Provides
| Type | Purpose |
|---|---|
ICommand |
Marker interface for command types |
ICommandHandler<TCommand> |
Contract for command handlers — returns Task<object?> |
ICommandProcessor |
Dispatches a command to its registered handler |
IQuery |
Marker interface for query types |
IQueryHandler<TQuery> |
Contract for query handlers — returns Task<object> |
IQueryProcessor |
Dispatches a query to its registered handler |
EmptyResult |
Sentinel return value for logically-void handlers |
Key Behaviour
- Command processing:
CommandProcessorresolvesICommandHandler<TCommand>from DI and invokes it. Resolution failures are wrapped inProcessCommandException. - Query processing:
QueryProcessorresolvesIQueryHandler<TQuery>from DI and invokes it. Resolution failures are wrapped inProcessQueryException. No validation step. - Each processor creates its own
IServiceScope, so handlers are resolved in a scoped lifetime.
Quick Start
// 1. Define a command
public class CreateOrderCommand : ICommand
{
public string ProductId { get; set; } = string.Empty;
public int Quantity { get; set; }
}
// 2. Implement a handler
public class CreateOrderCommandHandler : ICommandHandler<CreateOrderCommand>
{
public Task<object?> HandleAsync(CreateOrderCommand command, CancellationToken ct)
{
// ... create the order ...
return Task.FromResult<object?>(createdOrder);
}
}
// 3. Register in DI — scans the given assembly/assemblies for every
// ICommandHandler<T>/IQueryHandler<T> implementation and registers them,
// along with ICommandProcessor/IQueryProcessor
services.AddCqrs(typeof(CreateOrderCommandHandler).Assembly);
// For fine-grained control (e.g. overriding a single handler), register
// manually instead/in addition — AddCqrs uses TryAdd, so an existing
// registration wins:
// services.AddScoped<ICommandHandler<CreateOrderCommand>, CreateOrderCommandHandler>();
// services.AddSingleton<ICommandProcessor, CommandProcessor>();
// 4. Dispatch
var result = await commandProcessor.ProcessAsync(new CreateOrderCommand { ... }, ct);
Technical Documentation
Full interface reference, processor internals, and worked examples: src/LenzEng.Utilities.Cqrs — GitLab
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LenzEng.Utilities.Cqrs:
| Package | Downloads |
|---|---|
|
LenzEng.Utilities.Cqrs.FluentValidation
FluentValidation integration for LenzEng.Utilities.Cqrs — validates commands before dispatch. |
GitHub repositories
This package is not used by any popular GitHub repositories.