Its.Cqrs
Its.Cqrs copied to clipboard
redesign IEventSourcedRepository.Refresh
This method signature makes it easy for an aggregate to be in an incorrect state after refresh, if the following sequence occurs:
- Apply command
- Event updates aggregate state
- Save results in a concurrency exception
- Refresh is called
- Command is re-applied
A new aggregate instance needs to be sourced for this to work correctly. The method can still be used as a query optimization (not having to re-query the events already in memory) but it should return a new aggregate instance so that the possible effects of step 2 are undone.