Struct HistoricEvent
Pairs a persisted domain event with the authoritative stream version assigned to it by the event store.
public readonly record struct HistoricEvent : IEquatable<HistoricEvent>
- Implements
- Inherited Members
Remarks
Replay reads the version from this envelope, never from the event payload. An event's position in a stream is a persistence fact, established at append time; it is not a property the event can know about itself. A payload that carries its own version can only ever restate what the store already recorded, and cannot be trusted to do so — nothing in the type system compels a domain event to report the position it was actually written at.
Because replay never consults the payload, an event whose own version field is absent, defaulted, or wrong replays correctly, and a replay that has lost its versions cannot be constructed: there is no HistoricEvent without a Version.
Constructors
HistoricEvent(IDomainEvent, long)
Pairs a persisted domain event with the authoritative stream version assigned to it by the event store.
public HistoricEvent(IDomainEvent Event, long Version)
Parameters
EventIDomainEventThe domain event to replay.
VersionlongThe durable, zero-based position of
Eventin its aggregate's stream, as assigned by the store when the event was appended.
Remarks
Replay reads the version from this envelope, never from the event payload. An event's position in a stream is a persistence fact, established at append time; it is not a property the event can know about itself. A payload that carries its own version can only ever restate what the store already recorded, and cannot be trusted to do so — nothing in the type system compels a domain event to report the position it was actually written at.
Because replay never consults the payload, an event whose own version field is absent, defaulted, or wrong replays correctly, and a replay that has lost its versions cannot be constructed: there is no HistoricEvent without a Version.
Properties
Event
The domain event to replay.
public IDomainEvent Event { get; init; }
Property Value
Version
The durable, zero-based position of Event in its aggregate's stream, as assigned by the
store when the event was appended.
public long Version { get; init; }