Skip to content

Commit

Permalink
#3636 live projection should not call ApplyChangesAsync/store
Browse files Browse the repository at this point in the history
  • Loading branch information
erdtsieck committed Jan 24, 2025
1 parent 7bbe1a0 commit 401ea41
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Marten/Events/Aggregation/CustomProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,15 @@ async ValueTask<TDoc> ILiveAggregator<TDoc>.BuildAsync(IReadOnlyList<IEvent> eve
var documentSessionBase = session as DocumentSessionBase ?? (DocumentSessionBase)session.DocumentStore.LightweightSession();

var slice = new EventSlice<TDoc, TId>(default, session, events);
await ApplyChangesAsync(documentSessionBase, slice, cancellation).ConfigureAwait(false);

ApplyMetadata(slice.Aggregate, events.Last());
if (Lifecycle == ProjectionLifecycle.Live)
{
slice.Aggregate = await BuildAsync(session, slice.Aggregate, slice.Events()).ConfigureAwait(false);
ApplyMetadata(slice.Aggregate, events.Last());
}
else
{
await ApplyChangesAsync(documentSessionBase, slice, cancellation).ConfigureAwait(false);
}

return slice.Aggregate;
}
Expand Down

0 comments on commit 401ea41

Please sign in to comment.