SRenerCq 26.1.17

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

SRenerCQ

SRenerCQ is a simple CQRS implementation focused on using Dependency Injection to decouple commands and queries.

How to Use

Enabling SRenerCQ

Before using, it's important to enable SRenerCQ at the application by registering it in the service collection:

using SRenerCQ;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddSRenerCQ();

...

Using SRenerCQ

After implementing commands/queries as described below, invoking them is done using the ISender interface by Dependency Injection. To use them:

public class MyInjectedClass(ISender sender) : IMyInjectedClass
{
    public async Task ProcessCommand(){
        MyCommand command = new("Foo");
        await sender.Command(command);
    }

    public async Task ProcessQuery(){
        MyQuery query = new("Foo");
        string result = await sender.Query(query);

        Console.WriteLine(result);
    }
}

By convention, queries return data and commands perform state changes. This library allows commands to return a result (e.g., an identifier) — if you prefer strict CQRS, treat commands as void/Task and return read-model results via queries.

Commands

Commands could or could not return a value and are reserved to instructions that has the main goal of changing a piece of data. To use then:

Implement an ICommand and the corresponding ICommandHandler

public record MyCommand(string Name) : ICommand;

public class MyCommandHandler : ICommandHandler<MyCommand>
{
    public async Task Handle(MyCommand command, CancellationToken cancellationToken)
    {
        Console.WriteLine($"Hello {command.Name}");
    }
}

or, when it needs to return a value:

public record MyCommand(string Name) : ICommand<string>;

public class MyCommandHandler : ICommandHandler<MyCommand, string>
{
    public async Task<string> Handle(MyCommand command, CancellationToken cancellationToken)
    {
        return $"Hello {command.Name}";
    }
}

Queries

Queries are responsible to search and return a certain kind of data from the system. To accomplish that:

public record MyQuery(string Name) : IQuery<string>;

public class MyQueryHandler : IQueryHandler<MyQuery, string>
{
    public async Task<string> Handle(MyQuery query, CancellationToken cancellationToken)
    {
        return $"Hello {query.Name}";
    }
}

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

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
26.1.17 119 1/17/2026
26.1.0 112 1/10/2026