[BUG?] Do domain event handlers have to explicitly call SaveEntitiesAsync?
See original GitHub issueHello, first of all thanks again for this great reference project. I’m focusing on the Ordering bounded context, Im’ wondering if domain event handlers have to explicitly call UnitOfWork.SaveEntitiesAsync().
I understand that the Command Handler is responsible for persisting changes on one aggregate, and side effects on another aggregate have to be managed by a domain event triggering a domain event handler. The question is: does the domain event handler have to call SaveEntitiesAsync, when it is already called by the command handler?
For example, ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler explicitly calls
_buyerRepository.UnitOfWork.SaveEntitiesAsync()
, while UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler does not call _orderRepository.UnitOfWork.SaveEntitiesAsync()
.
Thanks for your time.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
Well, after a couple of years, I’d now say that the developer shouldn’t have to worry about this, because it’s a leaking detail. 😉
Ah! My immense inexperience in real-world projects implementing Event-Driven communication makes me believe at first that everything I see, it’s magic! That’s why I wanted to re-ask this question—to make sure that it’s actually not magic and discard the probability that some middleware is doing the trick.