ArturRios.Mediator
CQRS-style command and query dispatch on top of the built-in dependency injection container.
A lightweight implementation of the Mediator pattern giving a clean CQRS-style separation between commands (writes) and queries (reads) — with no container of its own.
What you get
CommandMediator,QueryMediator, and a combinedCommandQueryMediatorentry point.- Each command or query is dispatched to a dedicated handler resolved from a fresh DI scope, so scoped
dependencies such as a
DbContextare isolated per execution rather than shared across a request. - Synchronous and asynchronous variants for every handler type.
- Handlers return
DataOutput<T>/PaginatedOutput<T>envelopes fromArturRios.Output.
builder.Services.AddSingleton<CommandQueryMediator>();
// then register each handler
Install
dotnet add package ArturRios.Mediator
Family dependencies
ArturRios.Output3.3.1