AxisMediator 2.2.0

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

AxisMediator — Documentation

🌐 Português (documentação navegável)

An in-process CQRS mediator built on AxisResult — typed commands, queries and streaming queries; a typed pipeline (IAxisPipelineBehavior) with a shared AxisPipelineContext; an ambient IAxisMediator carrying TraceId/OriginId/JourneyId/AxisEntityId/CancellationToken; events flow through AxisBus; observability behaviours plug in from AxisLogger, AxisValidator, AxisTelemetry.

public record CreateOrderCommand(AxisEntityId CustomerId, AxisEntityId ProductId, int Quantity)
    : IAxisCommand<CreateOrderResponse>;

public record CreateOrderResponse(AxisEntityId OrderId) : IAxisCommandResponse;

public class CreateOrderHandler(IOrderFactory factory, IUnitOfWork uow)
    : IAxisCommandHandler<CreateOrderCommand, CreateOrderResponse>
{
    public Task<AxisResult<CreateOrderResponse>> HandleAsync(CreateOrderCommand cmd)
        => factory.CreateAsync(cmd)
            .ThenAsync(order => uow.SaveChangesAsync().Map(_ => order))
            .MapAsync(order => new CreateOrderResponse(order.OrderId));
}

// at the edge
var result = await mediator.Cqrs.ExecuteAsync<CreateOrderCommand, CreateOrderResponse>(cmd);

Use this page as a map: read the trunk below (~5 min) and jump straight to the detail of the group you need — without reading hundreds of lines.


The trunk (read first)

CQRS in 60 seconds

Concept Marker interface Handler What runs
Command with no response IAxisCommand IAxisCommandHandler<TCommand> Task<AxisResult>
Command with a typed response IAxisCommand<TResponse> (TResponse : IAxisCommandResponse) IAxisCommandHandler<TCommand, TResponse> Task<AxisResult<TResponse>>
Query with a typed response IAxisQuery<TResponse> (TResponse : IAxisQueryResponse) IAxisQueryHandler<TQuery, TResponse> Task<AxisResult<TResponse>>
Stream query with a typed item IAxisStreamQuery<TItem> IAxisStreamQueryHandler<TQuery, TItem> IAsyncEnumerable<TItem>
Event (fan-out, fire-and-forget) IAxisEvent IAxisEventHandler<TEvent> Task<AxisResult> (per handler)

→ CQRS — commands, queries, streams, events

The mediator surface

public interface IAxisMediator
{
    CancellationToken CancellationToken { get; }
    string TraceId { get; }
    string? OriginId { get; }
    string? JourneyId { get; }
    AxisEntityId? AxisEntityId { get; }
    IAxisMediatorHandler Cqrs { get; }
}

IAxisMediator is the ambient context for a request. Its properties come from IAxisMediatorContextAccessor (AsyncLocal-backed). The Cqrs property dispatches commands/queries/streams. → The mediator and the accessors

IAxisMediatorHandler — the dispatcher

public interface IAxisMediatorHandler
{
    Task<AxisResult>             ExecuteAsync<TCommand>(TCommand command);
    Task<AxisResult<TResponse>>  ExecuteAsync<TCommand, TResponse>(TCommand command);
    Task<AxisResult<TResponse>>  QueryAsync<TQuery, TResponse>(TQuery query);
    IAsyncEnumerable<TItem>      StreamAsync<TQuery, TItem>(TQuery query);
}

Four methods, one job: resolve the handler, build the pipeline, run it. A missing handler returns AxisError.NotFound("HANDLER_NOT_FOUND_X"). → Dispatching · IAxisMediatorHandler

Pipelines — IAxisPipelineBehavior

The mediator wraps every request in a pipeline of IAxisPipelineBehaviors (registered in DI as open-generics). Behaviours run outside-in: the first registered behaviour is the outermost wrapper; next() calls the inner one; the handler is innermost. → Pipeline behaviours · Pipeline context

Built-in behaviour — PerformanceBehavior

Opt-in IAxisPipelineBehavior<TRequest, TResponse> that warns when a request exceeds 500ms via IAxisLogger<TRequest>. → PerformanceBehavior

Installation

dotnet add package AxisMediator              # the mediator + accessors + dispatcher
dotnet add package AxisMediator.Contracts    # marker interfaces (rarely added alone)

The CQRS scanner lives in AxisMediator.DependencyInjection.AddCqrsMediator(assembly).

→ Full guide: Getting started


The map (jump to what you need)

Group You want to… Detail
CQRS model commands, queries, streams, events cqrs.md
Mediator · IAxisMediator ⭐ the ambient context every handler reads mediator-and-accessors.md
Dispatcher · IAxisMediatorHandler the four ExecuteAsync/QueryAsync/StreamAsync dispatching.md
Pipelines · IAxisPipelineBehavior write a cross-cutting behaviour pipeline-behaviors.md
Pipeline context pass values between behaviours pipeline-context.md
Performance behaviour the in-box slow-request warning performance-behavior.md
Registration & scanning AddAxisMediator + AddCqrsMediator(assembly) registration.md
Why? the case against MediatR why-axismediator.md
Reference every member at a glance api-reference.md

Start here: Getting started · CQRS · The mediator and the accessors

Fundamentals: Dispatching · IAxisMediatorHandler · Pipeline behaviours · Pipeline context

Reference & extras: Performance behaviour · Registration & scanning · Why AxisMediator? · API reference


Design principles

  1. CQRS is in the type system. IAxisCommand, IAxisQuery, IAxisEvent say what they are. Handlers cannot be confused for each other.
  2. Errors are values. Every dispatch returns AxisResult — even "handler not found" is a typed NotFound.
  3. Ambient context lives in AsyncLocal. TraceId/OriginId/JourneyId/AxisEntityId/CancellationToken travel without parameter threading.
  4. Pipelines are open-generic. Behaviours register against IAxisPipelineBehavior<> / <,> — one registration covers every request type.
  5. No "the mediator does everything". Sending an event is AxisBus. Validating is AxisValidator. Tracing is AxisTelemetry. The mediator dispatches.

License

Apache 2.0

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 (1)

Showing the top 1 NuGet packages that depend on AxisMediator:

Package Downloads
AxisMemoryBus

Part of the Axis Framework — an opinionated, ports-and-adapters .NET framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 381 7/21/2026
2.1.1 134 7/17/2026
2.1.0 136 7/17/2026
2.0.1 156 7/15/2026
2.0.0 143 7/15/2026