Class AggregateHydrator
Namespace: Cephalon.EventSourcing.Services
Assembly: Cephalon.EventSourcing.dll
Rehydrates aggregate state by replaying domain events from an event store.
public sealed class AggregateHydrator<TAggregate, TState> where TAggregate : IAggregate<TState>, new()Type Parameters
Section titled “Type Parameters”TAggregate
The aggregate type that applies domain events.
TState
The aggregate state shape.
Inheritance
Section titled “Inheritance”object ← AggregateHydrator<TAggregate, TState>
Inherited Members
Section titled “Inherited Members”object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
Section titled “Constructors”AggregateHydrator()
Section titled “ AggregateHydrator()”Initializes a new instance of the
public AggregateHydrator()Methods
Section titled “Methods”HydrateAsync(IEventStore, string, long, CancellationToken)
Section titled “ HydrateAsync(IEventStore, string, long, CancellationToken)”Rehydrates one aggregate state by replaying the requested event stream.
public Task<(TState State, long Version)> HydrateAsync(IEventStore eventStore, string streamId, long fromVersion = 0, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”eventStore IEventStore
The event store to read from.
streamId string
The stable stream identifier.
fromVersion long
The first version to replay. The default is 0.
cancellationToken CancellationToken
The token that cancels the operation.
Returns
Section titled “Returns”Task<(TState State, long Version)>
The rehydrated aggregate state and the latest version applied.