MinimalCqrs.Core 1.1.0

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

MinimalCQRS

A lightweight, dependency-free CQRS library for .NET
designed for Web APIs and Vertical Slice architecture.

MinimalCQRS provides pure CQRS without pipelines, behaviors, or framework lock-in.

  • Targets: .NET 8 / 9 / 10
  • Zero third-party dependencies
  • Strongly-typed dispatcher (no dynamic)
  • Built Web API–first

Author: livedcode
License: MIT
Current Version: 1.1.0


✨ Why MinimalCQRS?

MinimalCQRS is for developers who want:

  • ✔ Explicit Commands and Queries
  • ✔ Optional Command<TResult> return values
  • ✔ A clear validation pipeline
  • ✔ Strong typing throughout
  • ✔ Vertical Slice–friendly design
  • ✔ First-class ASP.NET Web API support
  • ✔ Deterministic behavior (no hidden pipelines)
  • ✔ Full unit & integration testability
  • ✔ No MediatR, no magic

📦 Core Concepts

✔ Commands

public sealed class CreateLogCommand : ICommand;
public sealed class CreateUserCommand : ICommand<int>;

Commands mutate state.

✔ Queries

public sealed class GetUserQuery : IQuery<UserDto>;

Queries never mutate state and never run validation.

✔ Dispatcher (v1.1.0)

Task SendAsync(ICommand command);
Task<TResult> SendAsync<TResult>(ICommand<TResult> command);
Task<TResult> QueryAsync<TResult>(IQuery<TResult> query);

Guarantees:

  • Validation always runs before handlers
  • Handlers are NOT invoked if validation fails
  • All validators are executed and errors are aggregated
  • Queries bypass validation entirely
  • Each dispatch executes in its own DI scope
  • No dynamic usage (strong typing only)

✔ Validation Pipeline (Commands only)

public interface ICommandValidator<TCommand>
{
    IEnumerable<string> Validate(TCommand command);
}
  • Multiple validators per command are supported
  • All validation errors are returned in a single response
  • Validators never throw – they return errors
  • Dispatcher throws a single CommandValidationException

🚀 Getting Started (Web API)

Register MinimalCQRS

Always register CQRS using a feature assembly marker:

public sealed class ApiFeatureAssemblyMarker { }
builder.Services.AddMinimalCqrs(
    typeof(ApiFeatureAssemblyMarker).Assembly
);

🧯 Error Handling

MinimalCQRS does not handle HTTP concerns.

Recommended pattern:

catch (CommandValidationException ex)
{
    context.Response.StatusCode = 400;
    await context.Response.WriteAsJsonAsync(new
    {
        errors = ex.Errors
    });
}

🧪 Testing Strategy (v1.1.0)

MinimalCQRS is fully testable without mocks.

  • Dispatcher execution flow
  • Validation aggregation
  • Handler invocation guarantees
  • Missing handler failures
  • Query execution without validation
  • End-to-end API integration tests

🧠 Design Principles

  • MinimalCQRS is infrastructure-only
  • No dependency on ASP.NET
  • No dependency on application/domain code
  • Validation belongs to the application layer
  • Commands mutate state, queries do not
  • Fail fast, fail clearly, fail consistently

📜 License

MIT License — see LICENSE.


⭐ Summary

MinimalCQRS is:

  • ✔ Explicit
  • ✔ Predictable
  • ✔ Strongly typed
  • ✔ Web-API ready
  • ✔ Fully testable
  • ✔ Free of hidden abstractions

A clean alternative to MediatR
for teams that want full control over CQRS.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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. 
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.1.0 100 1/3/2026
1.0.0 147 11/23/2025