Dosaic.Plugins.Handlers.Cqrs 1.0.25

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dosaic.Plugins.Handlers.Cqrs --version 1.0.25                
NuGet\Install-Package Dosaic.Plugins.Handlers.Cqrs -Version 1.0.25                
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="Dosaic.Plugins.Handlers.Cqrs" Version="1.0.25" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dosaic.Plugins.Handlers.Cqrs --version 1.0.25                
#r "nuget: Dosaic.Plugins.Handlers.Cqrs, 1.0.25"                
#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.
// Install Dosaic.Plugins.Handlers.Cqrs as a Cake Addin
#addin nuget:?package=Dosaic.Plugins.Handlers.Cqrs&version=1.0.25

// Install Dosaic.Plugins.Handlers.Cqrs as a Cake Tool
#tool nuget:?package=Dosaic.Plugins.Handlers.Cqrs&version=1.0.25                

Dosaic.Plugins.Handlers.Cqrs

Dosaic.Plugins.Handlers.Cqrs is a plugin that provides CQRS implementation for basic resource operations, automatically registering handlers and validators for CRUD operations.

Installation

To install the nuget package follow these steps:

dotnet add package Dosaic.Plugins.Handlers.Cqrs

Appsettings.yml

No specific configuration in appsettings.yml is required for this plugin.

Configuration in your plugin host

No specific configuration available.

Features

  • Automatic registration of default CRUD handlers:

    • Create (ICreateHandler<>)
    • Update (IUpdateHandler<>)
    • Delete (IDeleteHandler<>)
    • Get (IGetHandler<>)
    • GetList (IGetListHandler<>)
  • Auto-discovery and registration of custom handlers implementing IHandler

  • Auto-discovery and registration of custom validators implementing IBaseValidator


Example Usage

Example service using the create handler, all handlers are to be used in the same way

public class UserService
{
    private readonly ICreateHandler<UserResource> _createHandler;

    public UserService(ICreateHandler<UserResource> createHandler)
    {
        _createHandler = createHandler;
    }

    public async Task<UserResource> CreateUserAsync(string name, CancellationToken cancellationToken)
    {
        var newUser = new UserResource { Name = name };
        return await _createHandler.CreateAsync(newUser, cancellationToken);
    }
}

// Example validator
public class UserResourceValidator : ICreateValidator<UserResource>
{
    public void ValidateOnCreate(UserResource resource)
    {
        if (string.IsNullOrEmpty(resource.Name))
            throw new ValidationException("Name is required");
    }
}

// Example repository implementation or use a Dosaic.Plugins.Persistence plugin for a database of your choice
public class UserResourceRepository : IRepository<UserResource>
{
    public async Task<UserResource> AddAsync(UserResource entity, CancellationToken cancellationToken)
    {
        // Implementation details...
        return entity;
    }

    // Other repository methods...
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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 Dosaic.Plugins.Handlers.Cqrs:

Package Downloads
Dosaic.Plugins.Endpoints.RestResourceEntity

A plugin-first dotnet framework for rapidly building anything hosted in the web.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.30 25 1/30/2025
1.0.27 4 1/29/2025
1.0.26 3 1/29/2025
1.0.25 3 1/29/2025
1.0.18 60 1/23/2025
1.0.17 63 1/23/2025