SolTechnology.Core.CQRS 0.7.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SolTechnology.Core.CQRS --version 0.7.0
                    
NuGet\Install-Package SolTechnology.Core.CQRS -Version 0.7.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="SolTechnology.Core.CQRS" Version="0.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SolTechnology.Core.CQRS" Version="0.7.0" />
                    
Directory.Packages.props
<PackageReference Include="SolTechnology.Core.CQRS" />
                    
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 SolTechnology.Core.CQRS --version 0.7.0
                    
#r "nuget: SolTechnology.Core.CQRS, 0.7.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 SolTechnology.Core.CQRS@0.7.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=SolTechnology.Core.CQRS&version=0.7.0
                    
Install as a Cake Addin
#tool nuget:?package=SolTechnology.Core.CQRS&version=0.7.0
                    
Install as a Cake Tool

Overview

The SolTechnology.Core.CQRS library provides a complete CQRS (Command Query Responsibility Segregation) implementation built on MediatR. It includes the Result pattern for explicit success/failure handling, Chain handlers for complex multi-step operations, and automatic validation and logging through pipeline behaviors.

Registration

For installing the library, reference SolTechnology.Core.CQRS nuget package and invoke the appropriate registration methods:

// Register command handlers
services.RegisterCommands();

// Register query handlers
services.RegisterQueries();

// Register chain steps (for complex operations)
services.RegisterChain();

Configuration

No configuration is needed. The registration methods automatically:

  • Register all command and query handlers from the calling assembly
  • Configure FluentValidation for input validation
  • Add logging and validation pipeline behaviors

Usage

  1. Define a Query and Handler
public class GetUserQuery : IRequest<Result<User>>
{
    public int UserId { get; set; }
}

public class GetUserQueryHandler : IQueryHandler<GetUserQuery, User>
{
    public async Task<Result<User>> Handle(GetUserQuery request, CancellationToken cancellationToken)
    {
        var user = await _userRepository.GetById(request.UserId);

        if (user == null)
            return Result<User>.Fail("User not found");

        return Result<User>.Success(user);
    }
}
  1. Define a Command and Handler
public class CreateUserCommand : IRequest<Result>
{
    public string Name { get; set; }
    public string Email { get; set; }
}

public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
{
    public async Task<Result> Handle(CreateUserCommand request, CancellationToken cancellationToken)
    {
        await _userRepository.Create(new User
        {
            Name = request.Name,
            Email = request.Email
        });

        return Result.Success();
    }
}
  1. Add Validation (Optional)
public class CreateUserCommandValidator : AbstractValidator<CreateUserCommand>
{
    public CreateUserCommandValidator()
    {
        RuleFor(x => x.Name).NotEmpty().MaximumLength(100);
        RuleFor(x => x.Email).NotEmpty().EmailAddress();
    }
}
  1. Use Chain Pattern for Complex Operations
public class ComplexOperationContext : ChainContext<MyInput, MyOutput>
{
    public string IntermediateData { get; set; }
}

public class Step1 : IChainStep<ComplexOperationContext>
{
    public async Task<Result> Execute(ComplexOperationContext context)
    {
        // Step 1 logic
        context.IntermediateData = "processed";
        return Result.Success();
    }
}

public class ComplexOperationHandler : ChainHandler<MyInput, ComplexOperationContext, MyOutput>
{
    protected override async Task HandleChain()
    {
        await Invoke<Step1>();
        await Invoke<Step2>();
        await Invoke<Step3>();
    }
}
  1. Result Pattern Usage
var result = await _mediator.Send(new GetUserQuery { UserId = 1 });

if (result.IsSuccess)
{
    var user = result.Value;
    // Use the user
}
else
{
    var error = result.Error;
    // Handle the error
}
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 (2)

Showing the top 2 NuGet packages that depend on SolTechnology.Core.CQRS:

Package Downloads
SolTechnology.Core.Flow

Package Description

SolTechnology.Core.Hangfire

Durable, persistent event dispatch and recurring jobs for SolTechnology.Core.CQRS. Opt in with AddPersistentEvents() and your events survive process restarts via Hangfire storage; schedule recurring work with AddSolRecurringJob<TJob>(cron).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 123 7/6/2026
0.8.0 112 6/8/2026
0.7.0 263 5/8/2026
0.5.0 569 12/10/2025
0.2.4 455 10/6/2023
0.2.3 247 10/5/2023
0.2.2 578 10/31/2022
0.2.1 549 10/31/2022
0.2.0 531 10/26/2022