eQuantic.Core.CQS 2.4.0

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

eQuantic.Core.CQS

NuGet Build Status License

A modern, high-performance CQS/CQRS framework for .NET with pipeline behaviors, notifications, streaming, sagas, and distributed system support. MIT-licensed alternative to MediatR.

Features

  • Commands & Queries - Clear separation of read and write operations
  • Pipeline Behaviors - Cross-cutting concerns (logging, validation, etc.)
  • Notifications - Publish-subscribe pattern with multiple handlers
  • Streaming - IAsyncEnumerable support for large datasets
  • Sagas - Multi-step transactions with compensation
  • Outbox Pattern - Reliable message publishing
  • Job Scheduling - Deferred command execution
  • Paged Queries - Built-in pagination support
  • Modern .NET - Targets .NET 6, 8, and 9

Packages

Package Description NuGet
eQuantic.Core.CQS Core framework NuGet
eQuantic.Core.CQS.Abstractions Interfaces and contracts NuGet
eQuantic.Core.CQS.Generators Source generators NuGet

Persistence Providers

Package Provider Features
eQuantic.Core.CQS.Redis Redis Saga Repository, Outbox, Job Scheduler
eQuantic.Core.CQS.MongoDb MongoDB Saga Repository, Outbox, Job Scheduler
eQuantic.Core.CQS.PostgreSql PostgreSQL Saga Repository, Outbox, Job Scheduler
eQuantic.Core.CQS.EntityFramework EF Core Saga Repository, Outbox, Job Scheduler

Cloud Messaging

Package Provider Features
eQuantic.Core.CQS.Azure Azure Service Bus Outbox Publisher (Queue/Topic)
eQuantic.Core.CQS.AWS Amazon SQS Outbox Publisher

Telemetry Providers

Package Provider Features
eQuantic.Core.CQS.OpenTelemetry OpenTelemetry Distributed tracing, metrics
eQuantic.Core.CQS.ApplicationInsights Azure App Insights Distributed tracing, metrics
eQuantic.Core.CQS.Datadog Datadog APM Distributed tracing

Resilience Providers

Package Provider Features
eQuantic.Core.CQS.Resilience Default Saga timeout, compensation
eQuantic.Core.CQS.Polly Polly Retry, circuit breaker
eQuantic.Core.CQS.Resilience.Redis Redis Dead letter queue
eQuantic.Core.CQS.Resilience.ServiceBus Azure Service Bus Dead letter queue

Installation

# Core package
dotnet add package eQuantic.Core.CQS

# Optional: Provider packages
dotnet add package eQuantic.Core.CQS.Redis
dotnet add package eQuantic.Core.CQS.Azure

Quick Start

1. Register Services

// Basic setup
services.AddCQS(options => options
    .FromAssemblyContaining<Program>());

// With providers
services.AddCQS(options => options
    .FromAssemblyContaining<Program>()
    .UsePreProcessor = true;
    .UseRedis(redis => redis.ConnectionString = "localhost:6379")
    .UseAzureServiceBus(sb => {
        sb.ConnectionString = "Endpoint=sb://...";
        sb.QueueOrTopicName = "outbox";
    }));

2. Define a Query

public record GetUserByIdQuery(Guid Id) : IQuery<UserDto>;

3. Create a Handler

public class GetUserByIdHandler : IQueryHandler<GetUserByIdQuery, UserDto>
{
    public async Task<UserDto> Execute(GetUserByIdQuery query, CancellationToken ct)
    {
        return new UserDto(query.Id, "John Doe");
    }
}

4. Execute via Mediator

public class UsersController : ControllerBase
{
    private readonly IMediator _mediator;

    [HttpGet("{id}")]
    public async Task<UserDto> Get(Guid id)
        => await _mediator.ExecuteAsync(new GetUserByIdQuery(id));
}

Advanced Features

Commands

// Command without result
public record DeleteUserCommand(Guid Id) : ICommand;

// Command with result
public record CreateUserCommand(string Name) : ICommand<Guid>;

Notifications (Pub/Sub)

public record UserCreatedNotification(Guid UserId) : INotification;

public class SendWelcomeEmailHandler : INotificationHandler<UserCreatedNotification>
{
    public async Task Handle(UserCreatedNotification notification, CancellationToken ct)
    {
        // Send email
    }
}

// Publish to all handlers
await _notificationPublisher.Publish(new UserCreatedNotification(userId));

Streaming

public record GetAllUsersStreamQuery : IStreamQuery<UserDto>;

await foreach (var user in _mediator.ExecuteStreamAsync(new GetAllUsersStreamQuery()))
{
    Console.WriteLine(user.Name);
}

Sagas (Multi-step Transactions)

public class OrderSaga : Saga<OrderSagaData>
{
    protected override void ConfigureSteps()
    {
        Step("ProcessPayment",
            execute: async (data, ct) => { /* charge */ },
            compensate: async (data, ct) => { /* refund */ });

        Step("ReserveInventory",
            execute: async (data, ct) => { /* reserve */ },
            compensate: async (data, ct) => { /* release */ });

        Step("Ship",
            execute: async (data, ct) => { /* ship */ },
            compensate: async (data, ct) => { /* cancel shipment */ });
    }
}

// Execute - automatic compensation on failure
var result = await saga.Execute(new OrderSagaData { OrderId = orderId });
if (!result.IsSuccess)
{
    Console.WriteLine($"Saga failed: {result.Error?.Message}");
}

Azure Service Bus Integration

services.AddCQSAzureServiceBus(options =>
{
    options.ConnectionString = "Endpoint=sb://...";
    options.QueueOrTopicName = "outbox-messages";
    options.UseTopic = false;
});

// Publish outbox messages
await _outboxPublisher.PublishAsync(message);
await _outboxPublisher.PublishBatchAsync(messages);

AWS SQS Integration

services.AddCQSAwsSqs(options =>
{
    options.QueueUrl = "https://sqs.us-east-1.amazonaws.com/123456789/my-queue";
    options.Region = "us-east-1";
});

Pipeline Behaviors

public class LoggingBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
{
    public async Task<TResponse> Execute(TRequest request, CancellationToken ct, HandlerDelegate<TResponse> next)
    {
        _logger.LogInformation("Handling {Request}", typeof(TRequest).Name);
        var response = await next();
        _logger.LogInformation("Handled {Request}", typeof(TRequest).Name);
        return response;
    }
}

Comparison with MediatR

Feature eQuantic.Core.CQS MediatR
License MIT ✅ Commercial 💰
Sagas Built-in ✅
Outbox Pattern Built-in ✅
Cloud Messaging Azure/AWS ✅
Paged Queries Built-in ✅ Manual
Streaming IAsyncEnumerable ✅ IAsyncEnumerable
Notifications
Pipeline Behaviors

License

MIT License - See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 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 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. 
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 eQuantic.Core.CQS:

Package Downloads
eQuantic.Core.CQS.OpenTelemetry

OpenTelemetry integration for eQuantic CQS. Provides distributed tracing and metrics for commands, queries, sagas, and outbox operations.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.0 199 2/14/2026
2.3.1 124 2/14/2026
2.3.0 144 12/28/2025
2.1.0 135 12/27/2025
1.0.5 126 12/27/2025
1.0.4 132 12/27/2025
1.0.0 211 12/25/2025
1.0.0-ci0002 196 12/25/2025
1.0.0-ci.2 154 12/25/2025
0.1.0-beta1 701 10/7/2019