Skip to content

Commit

Permalink
#60 Fixing ordering... a long unseen bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmdotnet committed Jul 17, 2017
1 parent 1713f6d commit 98e6aaf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cqrs.Modelling" version="1.601.917" />
<package id="Cqrs.Modelling" version="2.1.1347.590" />
</packages>
4 changes: 3 additions & 1 deletion Framework/Cqrs/Domain/AggregateRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public virtual void Save<TAggregateRoot>(TAggregateRoot aggregate, int? expected
var eventsToPublish = new List<IEvent<TAuthenticationToken>>();

int i = 0;
int version = aggregate.Version;
foreach (IEvent<TAuthenticationToken> @event in uncommittedChanges)
{
if (@event.Id == Guid.Empty)
Expand All @@ -59,8 +60,9 @@ public virtual void Save<TAggregateRoot>(TAggregateRoot aggregate, int? expected
throw new AggregateOrEventMissingIdException(aggregate.GetType(), @event.GetType());

i++;
version++;

@event.Version = aggregate.Version + i;
@event.Version = version;
@event.TimeStamp = DateTimeOffset.UtcNow;
@event.CorrelationId = CorrelationIdHelper.GetCorrelationId();
EventStore.Save(aggregate.GetType(), @event);
Expand Down
2 changes: 1 addition & 1 deletion Framework/Cqrs/Domain/AggregateRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void ApplyChange(IEvent<TAuthenticationToken> @event, bool isEventReplay
this.AsDynamic().Apply(@event);
if (!isEventReplay)
{
Changes = new ReadOnlyCollection<IEvent<TAuthenticationToken>>(new []{@event}.Concat(Changes).ToList());
Changes = new ReadOnlyCollection<IEvent<TAuthenticationToken>>(Changes.Concat(new[] { @event }).ToList());
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Modelling/UmlProfiles/Cqrs.Modelling.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>Cqrs.Modelling</id>
<title>Cqrs.net profiles for UML modeling</title>
<title>Visual Studio UML modelling profiles for CQRS.NET</title>
<version>$version$</version>
<authors>Chinchilla Software</authors>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
Expand Down

0 comments on commit 98e6aaf

Please sign in to comment.