SolTechnology.Core.CQRS 0.5.0

dotnet add package SolTechnology.Core.CQRS --version 0.5.0
                    
NuGet\Install-Package SolTechnology.Core.CQRS -Version 0.5.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.5.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.5.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.5.0
                    
#r "nuget: SolTechnology.Core.CQRS, 0.5.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.5.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.5.0
                    
Install as a Cake Addin
#tool nuget:?package=SolTechnology.Core.CQRS&version=0.5.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 (3)

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

Package Downloads
SolTechnology.Core.Api

ASP.NET Core API utilities including header-based API versioning, exception handling middleware, response envelope filters, and integration testing fixtures. Perfect foundation for building clean, testable APIs with consistent error handling and response formatting.

SolTechnology.Core.Flow

Package Description

SolTechnology.Core.Story

Story Framework - Unified workflow orchestration for multi-step business processes. Supports both simple automated chains and pausable workflows with persistence. Features Tale Code philosophy with StoryHandler, Chapters, and Context for readable, maintainable business logic.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 493 12/10/2025
0.2.4 405 10/6/2023
0.2.3 210 10/5/2023
0.2.2 544 10/31/2022
0.2.1 518 10/31/2022
0.2.0 504 10/26/2022