CqsLite 1.1.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package CqsLite --version 1.1.0
                    
NuGet\Install-Package CqsLite -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="CqsLite" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CqsLite" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CqsLite" />
                    
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 CqsLite --version 1.1.0
                    
#r "nuget: CqsLite, 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 CqsLite@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=CqsLite&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CqsLite&version=1.1.0
                    
Install as a Cake Tool

CqsLite

CqsLite is a lightweight library for implementing the Command–Query Separation (CQS) pattern in .NET applications. It provides a simple, extensible way to decouple your business logic using command and query handlers, without relying on complex frameworks.


✨ Features

  • ✅ Lightweight and minimal
  • 🧱 Built around ICommand, IQuery<TQuery, TResult>, and their respective handlers
  • ⚙️ Simple dispatcher pattern (ICommandDispatcher, IQueryDispatcher)
  • 🔍 Automatic registration via reflection (AddCqsLite(...))
  • 🔌 Fully compatible with ASP.NET Core and .NET dependency injection

📦 Installation

You can install CqsLite directly from NuGet:

dotnet add package CqsLite

Or via the Package Manager Console:

Install-Package CqsLite

🚀 Getting Started

1. Define a Command or Query

public record CreateUserCommand(string Name, string Email) : ICommand;
public record GetUserByIdQuery(Guid Id) : IQuery<UserDto>;

2. Create a Handler

public class CreateUserCommandHandler : ICommandHandler<CreateUserCommand>
{
    public Task HandleAsync(CreateUserCommand command, CancellationToken cancellationToken)
    {
        // Your logic here...
        return Task.CompletedTask;
    }
}

public class GetUserByIdQueryHandler : IQueryHandler<GetUserByIdQuery, UserDto>
{
    public Task<UserDto> HandleAsync(GetUserByIdQuery query, CancellationToken cancellationToken)
    {
        // Your logic here...
        return Task.FromResult(new UserDto { Id = query.Id, Name = "John" });
    }
}

3. Register CqsLite

builder.Services.AddCqsLite(typeof(Program).Assembly); // Automatically scans your handlers

4. Dispatch

var result = await _queryDispatcher.DispatchAsync<GetUserByIdQuery, UserDto>(new GetUserByIdQuery(id));
await _commandDispatcher.DispatchAsync<CreateUserCommand>(new CreateUserCommand("Alice", "alice@example.com"));

🧪 Testing

Includes unit and integration tests for:

  • Dispatcher behavior
  • Handler resolution via DI
  • Reflection-based service registration

Run tests with:

dotnet test

📂 Project Structure

CqsLite/
├── Abstractions/        # ICommand, IQuery<TResult>, and handler interfaces
├── Dispatching/         # CommandDispatcher and QueryDispatcher
├── Extensions/          # IServiceCollection.AddCqsLite()
└── CqsLite.csproj

📄 License

MIT © Miguel

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 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 was computed.  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