![]() |
VOOZH | about |
dotnet add package ResultCQRS --version 1.0.8
NuGet\Install-Package ResultCQRS -Version 1.0.8
<PackageReference Include="ResultCQRS" Version="1.0.8" />
<PackageVersion Include="ResultCQRS" Version="1.0.8" />Directory.Packages.props
<PackageReference Include="ResultCQRS" />Project file
paket add ResultCQRS --version 1.0.8
#r "nuget: ResultCQRS, 1.0.8"
#:package ResultCQRS@1.0.8
#addin nuget:?package=ResultCQRS&version=1.0.8Install as a Cake Addin
#tool nuget:?package=ResultCQRS&version=1.0.8Install as a Cake Tool
Library featuring CQRS pattern and mediator implementations in conjuction with functional Results to achieve exception-safe operations.
Uses a functional Result approach for failure-prone operations.
To utilize all features using Autofac is required.
ICommand and IQuery abstractionsICommandHandler and IQueryHandler abstractionsICommandDispatcher and IQueryDispatcher abstractions and default implementationsFor both commands and queries, there are two return options - one that only returns a Result and one that returns an additional entity/DTO contained within the Result.
Every handler must return a Result struct which determines whether the operation succedeed or not, handlers may or may not return additional results contained within the Result struct.
To register the library with the DI container use the ContainerBuilder or IServiceCollection extension methods provided by the library:
builder.AddResultCQRS(assembliesToScan);
To register decorators (or adapters) use:
If you're using Autofac (or built-in attribute based Autofac) - you can register multiple decorators and they'll be applied in the order that you register them - read more at Autofac's docs regarding decorators and adapters.
Documentation available at https://docs.result-cqrs.mikym.me/.
Library offers a simple error catching and logging within the provided default Dispatcher implementations.
A command without a concrete result:
public record SimpleCommand : ICommand
{
public bool IsSuccess { get; }
public SimpleCommand(bool isSuccess = true)
=> IsSuccess = isSuccess;
}
And a handler that handles it:
public class SimpleCommandHandler : ICommandHandler<SimpleCommand>
{
public async Task<Result> HandleAsync(SimpleCommand command)
{
if (command.IsSuccess)
return Result.FromSuccess();
return new InvalidOperationError();
}
}
A command with a concrete result:
public record SimpleCommandWithConcreteResult : ICommand<int>
{
public bool IsSuccess { get; }
public SimpleCommandWithConcreteResult(bool isSuccess = true)
=> IsSuccess = isSuccess;
}
And a handler that handles it:
public class SimpleCommandHandlerWithConcreteResult : ICommandHandler<SimpleCommandWithConcreteResult, int>
{
public async Task<Result<int>> HandleAsync(SimpleCommandWithConcreteResult command)
{
if (command.IsSuccess)
return 1;
return new InvalidOperationError();
}
}
Then in your service you can use:
public class Service : IService
{
private readonly ICommandDispatcher _commandDispatcher;
public Service(ICommandDispatcher commandDispatcher)
=> _commandDispatcher = commandDispatcher;
public async Task<Result> DoAsync()
{
var result = await _commandDispatcher.DispatchAsync(command)
return new InvalidOperationError();
}
}
Using queries is pretty much same.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on ResultCQRS:
| Package | Downloads |
|---|---|
|
ResultCQRS.Autofac
Library featuring CQRS pattern. |
This package is not used by any popular GitHub repositories.