-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AggregateRoot version never updated #7
Comments
This should be incremented when applying any change to the private void ApplyChange(Event @event, bool isNew)
{
this.AsDynamic().Apply(@event);
if(isNew) _changes.Add(@event);
this.Version++
} (Greg may hit me if I'm wrong) |
That's correct, @beachwalker! You are not wrong :) |
Indeed. |
The version of the AggregateRoot gets incremented whenever a new event is applied.
I'd say that the version should be updated at two different points:
I wouldn't increase the version number directly after an event is applied and the aggregate is still in an uncommitted state, because then we'll lose the original version number and won't be able to do optimistic concurrency control. Consider the following scenario:
|
We do not lose the original version number at all.
|
True! That's a nice way to do the check. |
Indeed. There are a lot of ways to do it right. For instance, in my own implementation of event store I do the concurrency check in another way |
@Narvalex your link is broken. Can you direct us to your implementation? |
It loos like the
AggregateRoot
Version
field is never updated. It should probably be updated at the end of theLoadsFromHistory
method (which should probably be renamedLoadFromHistory
), with the version of the last event replayed.The text was updated successfully, but these errors were encountered: