/// <inheritdoc /> public async Task <IExecutionResult> Handle( CommandRequest <TCommand> request, CancellationToken cancellationToken, RequestHandlerDelegate <IExecutionResult> next) { var scope = request.CreateTransactionalScope(transactionStore, aggregateStore, integrationEventStore); var result = await next(); if (!result.Success) { return(result); } // If there are changes in domain, then there must be a domain event, // therefore we have something to save. if (result is IntegrationEventExecutionResult deer) { await scope.CommitAsync(request.Command.Id, deer.Event); } return(result); }