Skip to content

Commit

Permalink
Cast based on StreamIdentity
Browse files Browse the repository at this point in the history
  • Loading branch information
erdtsieck committed Feb 6, 2025
1 parent 7f92687 commit 11d8dc6
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/Marten/Events/Aggregation/CustomProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async ValueTask<TDoc> ILiveAggregator<TDoc>.BuildAsync(IReadOnlyList<IEvent> eve
var documentSessionBase = session as DocumentSessionBase ?? (DocumentSessionBase)session.DocumentStore.LightweightSession();

var latestEvent = events.Last();
var streamId = IdentityFromEvent(latestEvent);
var streamId = IdentityFromEvent(documentSessionBase.Options.EventGraph.StreamIdentity, latestEvent);
var slice = new EventSlice<TDoc, TId>(streamId, session, events);
if (Lifecycle == ProjectionLifecycle.Live)
{
Expand Down Expand Up @@ -420,16 +420,6 @@ public IAggregateCache<TId, TDoc> CacheFor(Tenant tenant)
}
}

public TId IdentityFromEvent(IEvent e)
{
if (typeof(TId) == typeof(Guid))
{
return e.StreamId.To<TId>();
}

return e.StreamKey.To<TId>();
}
public TId IdentityFromEvent(StreamIdentity streamIdentity, IEvent e) =>
streamIdentity == StreamIdentity.AsGuid ? e.StreamId.To<TId>() : e.StreamKey.To<TId>();
}



0 comments on commit 11d8dc6

Please sign in to comment.