LenzEng.Utilities.Cqrs.Rest
0.3.0
dotnet add package LenzEng.Utilities.Cqrs.Rest --version 0.3.0
NuGet\Install-Package LenzEng.Utilities.Cqrs.Rest -Version 0.3.0
<PackageReference Include="LenzEng.Utilities.Cqrs.Rest" Version="0.3.0" />
<PackageVersion Include="LenzEng.Utilities.Cqrs.Rest" Version="0.3.0" />
<PackageReference Include="LenzEng.Utilities.Cqrs.Rest" />
paket add LenzEng.Utilities.Cqrs.Rest --version 0.3.0
#r "nuget: LenzEng.Utilities.Cqrs.Rest, 0.3.0"
#:package LenzEng.Utilities.Cqrs.Rest@0.3.0
#addin nuget:?package=LenzEng.Utilities.Cqrs.Rest&version=0.3.0
#tool nuget:?package=LenzEng.Utilities.Cqrs.Rest&version=0.3.0
LenzEng.Utilities.Cqrs.Rest
ASP.NET Core integration for LenzEng.Utilities.Cqrs. Converts the raw results your command/query handlers return into IActionResult, so controllers never construct HTTP responses by hand.
What It Provides
| Type | Purpose |
|---|---|
AddCqrsRest() |
Registers IControllerCommandProcessor/IControllerQueryProcessor |
IControllerCommandProcessor / IControllerQueryProcessor |
Resolve and invoke the registered REST handler for a command/query, returning IActionResult directly |
AddCreatedAtRouteControllerCommand<TCommand, TResult>(...) |
Registers a command whose handler creates a resource → 201 Created with a Location header |
AddCNoContentControllerCommand<TCommand>() |
Registers a command → 204 No Content |
AddControllerQuery<TQuery>(...) |
Registers a query → 200 OK |
ControllerCommandHandlerBase<T> / ControllerQueryHandlerBase<T> |
Base classes for hand-written handlers the generic ones don't cover — expose Ok/NoContent/NotFound/BadRequest/CreatedAtRoute helpers |
Key Behaviour
404 Not Foundhappens automatically when a handler returnsLenzEng.Utilities.Cqrs.NotFoundMarkerinstead of a result — no exception needed.400 Bad Requesthappens automatically ifLenzEng.Utilities.Cqrs.FluentValidation'sValidateCommandExceptionis thrown, with the validation errors in the response body — this package doesn't reference that one, it just catches the exception type by name from the core package.- Conversion functions are typed as
Func<object, object>rather thanFunc<TDomain, TDto>on purpose, so the generic handlers stay decoupled from your domain/DTO types — the cast happens inside the converter you supply.
Quick Start
// 1. Register the core CQRS processors (from LenzEng.Utilities.Cqrs) and this package's
builder.Services.AddCqrs(typeof(CreateOrderCommandHandler).Assembly);
builder.Services.AddCqrsRest();
// 2. Configure each command/query
builder.Services.AddCreatedAtRouteControllerCommand<CreateOrderCommand, Order>(opts =>
{
opts.RouteName = "GetOrderById";
opts.IdProperty = o => o.Id;
});
builder.Services.AddCNoContentControllerCommand<CancelOrderCommand>();
builder.Services.AddControllerQuery<GetOrderByIdQuery>();
// 3. Controllers just dispatch — no manual IActionResult construction
public class OrdersController : ControllerBase
{
private readonly IControllerCommandProcessor _commands;
private readonly IControllerQueryProcessor _queries;
public OrdersController(IControllerCommandProcessor commands, IControllerQueryProcessor queries)
{
_commands = commands;
_queries = queries;
}
[HttpPost]
public Task<IActionResult> Create(CreateOrderCommand command, CancellationToken ct)
=> _commands.ProcessAsync(command, ct);
[HttpGet("{id:guid}", Name = "GetOrderById")]
public Task<IActionResult> GetById(Guid id, CancellationToken ct)
=> _queries.ProcessAsync(new GetOrderByIdQuery { OrderId = id }, ct);
}
Technical Documentation
Full reference and worked examples: src/LenzEng.Utilities.Cqrs.Rest — GitLab
See the Packages Work Together
The sample project's README is the best place to go next: a small, runnable movie-catalog API built on all three packages — LenzEng.Utilities.Cqrs, this one, and LenzEng.Utilities.Cqrs.FluentValidation — together. It's a genuinely good, step-by-step guide to how the three fit together in practice: how a request flows through every layer, what each line of DI registration actually does, and two worked recipes for adding a new endpoint from scratch. Written to be followable even if you're fairly new to the pattern.
| 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
- LenzEng.Utilities.Cqrs (>= 0.3.0)
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.3.0 | 38 | 7/12/2026 |