LiteCqrs.Net 1.0.1

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

LiteCqrs.Net

Build Tests NuGet Downloads License: MIT

A lightweight, dynamic-free, CQRS-flavored in-process mediator for .NET — an alternative to MediatR that keeps an explicit Command/Query split instead of a unified IRequest. Multi-targets netstandard2.0 (max reach: .NET Framework 4.6.1+, Mono, Unity) and net10.0 (in-box BCL, no polyfills).

What it does

  • ICommand<TResponse> / IQuery<TResponse> — commands change state, queries read; each has exactly one handler (ICommandHandler<,> / IQueryHandler<,>), dispatched via ISender.Send(...).
  • Dynamic-free dispatch: per-request-type wrapper classes cached in a process-lifetime ConcurrentDictionary, built once via reflection and never touched again — no dynamic, no per-call reflection after the first dispatch of a given request type.
  • Ordered pipeline behaviors (IPipelineBehavior<,>) — logging, validation, transactions, authorization, whatever you need. First-registered is outermost. Generic constraints on your behavior (e.g. where TRequest : ICommand<TResponse>) opt it in only for the requests that satisfy them.
  • Notifications / pub-sub (INotification / INotificationHandler<> / IPublisher.Publish) — zero-or-more handlers per notification, run sequentially (safe with scoped, non-thread-safe dependencies like an EF Core DbContext), failures isolated and aggregated rather than fail-fast — pluggable via INotificationPublisher if you need a different strategy.
  • Exception behaviors (IRequestExceptionHandler<,,> / IRequestExceptionAction<,>) — resolve by exception-type hierarchy (most-derived first), let a handler recover an exception into a response, or run an action that always fires regardless of recovery.
  • Streaming requests (IStreamRequest<> / IStreamRequestHandler<,> / ISender.CreateStream) — lazy IAsyncEnumerable<T> responses with their own composable IStreamPipelineBehavior<,>.
  • Flexible registrationAddLiteCqrs(cfg => { cfg.RegisterServicesFromAssembly(...); ... }) scans one or more assemblies, catches duplicate handler registrations for commands/queries eagerly (a footgun MS DI otherwise resolves silently as "last one wins"), and lets you configure the service lifetime (defaults to Scoped, not MediatR's Transient).

Install

dotnet add package LiteCqrs.Net

Register

using LiteCqrs.Behaviors;
using LiteCqrs.DependencyInjection;

builder.Services.AddLiteCqrs(cqrs =>
{
    cqrs.RegisterServicesFromAssemblyContaining<Program>();
    cqrs.Lifetime = ServiceLifetime.Scoped; // default; set explicitly for clarity if you like

    // First added = outermost.
    cqrs.AddOpenBehavior(typeof(LoggingBehavior<,>));   // ready-made, ships in LiteCqrs.Behaviors
    cqrs.AddOpenBehavior(typeof(MyValidationBehavior<,>));
    cqrs.AddOpenBehavior(typeof(MyUnitOfWorkBehavior<,>));
});

Then inject ISender:

public sealed class CreateOrderEndpoint(ISender sender)
{
    public Task<Result<OrderDto>> Post(CreateOrderCommand command, CancellationToken ct) =>
        sender.Send(command, ct);
}

Why not just MediatR?

MediatR is unified around IRequest<TResponse>; LiteCqrs.Net keeps commands and queries as distinct types on purpose — if your codebase already thinks in CQRS terms, the type system should say so. Beyond that, the two libraries solve the same problem in a similar shape (pipeline behaviors, notifications, streaming); pick whichever fits your project's conventions.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.1 551 7/24/2026
1.0.0 121 7/24/2026