Skip to content

Commit

Permalink
Ensure that applying events to an aggregate returns the aggregate eve…
Browse files Browse the repository at this point in the history
…n if there are no events to apply.
  • Loading branch information
elexisvenator authored and jeremydmiller committed Mar 25, 2024
1 parent 96a9e20 commit 8ef01d8
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,11 @@ private void buildLiveAggregationType(GeneratedAssembly assembly)

buildMethod.DerivedVariables.Add(Variable.For<IQuerySession>("(IQuerySession)session"));

buildMethod.Frames.Code("if (!events.Any()) return null;");

buildMethod.Frames.Add(new DeclareAggregateFrame(typeof(T)));

var callCreateAggregateFrame = new CallCreateAggregateFrame(_createMethods);

// This is the existing snapshot passed into the LiveAggregator
var snapshot = buildMethod.Arguments.Single(x => x.VariableType == typeof(T));
buildMethod.Frames.Code($"if (!events.Any()) return {snapshot.Usage};");

var callCreateAggregateFrame = new CallCreateAggregateFrame(_createMethods);
callCreateAggregateFrame.CoalesceAssignTo(snapshot);

buildMethod.Frames.Add(callCreateAggregateFrame);
Expand Down

0 comments on commit 8ef01d8

Please sign in to comment.