2.0.0-beta
Pre-release
Pre-release
Breaking Changes
- All packages now target
netstandard2.1
. - It is now needed that the two decorators
softaware.Cqs.SimpleInjector.PublicCommandHandlerDecorator
andsoftaware.Cqs.SimpleInjector.PublicQueryHandlerDecorator
are registered as last decorator in the chain when usingsoftaware.Cqs.SimpleInjector.DynamicCommandProcessor
andsoftaware.Cqs.SimpleInjector.DynamicQueryProcessor
. This is needed so that the dynamic processors can call the correct overload of theHandleAsync
method. Secondly this is needed when trying to call aninternal
decorator or aninternal
handler. If these two decorators are not registered, an exception will be thrown when trying to callExecuteAsync
on either theICommandProcessor
orIQueryProcessor
. See here for more details. - The package
softaware.Cqs.EntityFramework
is deprecated and no longer supported. It has been removed from this release.
New Features
-
It is now possible to pass a
CancellationToken
when executing command handlers and query handlers. So it is now easily possible to cancel the execution of commands and queries. To use the cancellable version, implement theHandleAsync(command, token)
default interface method and delegate to this implementation in theHandleAsync(command)
method:internal class LongRunningCommandHandler : ICommandHandler<LongRunningCommand> { public Task HandleAsync(LongRunningCommand command) { return this.HandleAsync(command, default); } public async Task HandleAsync(LongRunningCommand command, CancellationToken cancellationToken) { await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken); } }
Note: For this to work, all existing Decorators must override the
HandleAsync(command, token)
method and pass thecancellationToken
to the inner handlers.