Dosaic.Plugins.Handlers.Cqrs
1.0.27
See the version list below for details.
dotnet add package Dosaic.Plugins.Handlers.Cqrs --version 1.0.27
NuGet\Install-Package Dosaic.Plugins.Handlers.Cqrs -Version 1.0.27
<PackageReference Include="Dosaic.Plugins.Handlers.Cqrs" Version="1.0.27" />
paket add Dosaic.Plugins.Handlers.Cqrs --version 1.0.27
#r "nuget: Dosaic.Plugins.Handlers.Cqrs, 1.0.27"
// Install Dosaic.Plugins.Handlers.Cqrs as a Cake Addin #addin nuget:?package=Dosaic.Plugins.Handlers.Cqrs&version=1.0.27 // Install Dosaic.Plugins.Handlers.Cqrs as a Cake Tool #tool nuget:?package=Dosaic.Plugins.Handlers.Cqrs&version=1.0.27
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<>
)
- Create (
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 | Versions 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. |
-
net9.0
- Dosaic.Extensions.Abstractions (>= 1.0.27)
- Dosaic.Hosting.Abstractions (>= 1.0.27)
- Dosaic.Plugins.Handlers.Abstractions.Cqrs (>= 1.0.27)
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.