Class EventStore<TAuthenticationToken>
Stores instances of IEvent<TAuthenticationToken> for replay, IAggregateRoot<TAuthenticationToken> and ISaga<TAuthenticationToken> rehydration.
Inheritance
Inherited Members
Namespace: Cqrs.Events
Assembly: Cqrs.dll
Syntax
public abstract class EventStore<TAuthenticationToken> : IEventStore<TAuthenticationToken>
Type Parameters
Name | Description |
---|---|
TAuthenticationToken | The System.Type of the authentication token. |
Constructors
EventStore(IEventBuilder<TAuthenticationToken>, IEventDeserialiser<TAuthenticationToken>, ILogger)
Instantiates a new instance of EventStore<TAuthenticationToken>.
Declaration
protected EventStore(IEventBuilder<TAuthenticationToken> eventBuilder, IEventDeserialiser<TAuthenticationToken> eventDeserialiser, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
IEventBuilder<TAuthenticationToken> | eventBuilder | |
IEventDeserialiser<TAuthenticationToken> | eventDeserialiser | |
cdmdotnet.Logging.ILogger | logger |
Fields
CqrsEventStoreStreamNamePattern
The pattern used to generate the stream name.
Declaration
protected const string CqrsEventStoreStreamNamePattern = "{0}/{1}"
Field Value
Type | Description |
---|---|
System.String |
Properties
EventBuilder
The IEventBuilder<TAuthenticationToken> used to build events.
Declaration
protected IEventBuilder<TAuthenticationToken> EventBuilder { get; set; }
Property Value
Type | Description |
---|---|
IEventBuilder<TAuthenticationToken> |
EventDeserialiser
The IEventDeserialiser<TAuthenticationToken> used to deserialise events.
Declaration
protected IEventDeserialiser<TAuthenticationToken> EventDeserialiser { get; set; }
Property Value
Type | Description |
---|---|
IEventDeserialiser<TAuthenticationToken> |
Logger
The cdmdotnet.Logging.ILogger to use.
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ILogger |
TelemetryHelper
The cdmdotnet.Logging.ITelemetryHelper to use.
Declaration
protected ITelemetryHelper TelemetryHelper { get; set; }
Property Value
Type | Description |
---|---|
cdmdotnet.Logging.ITelemetryHelper |
Methods
GenerateStreamName(Type, IEvent<TAuthenticationToken>)
Generate a unique stream name based on the provided aggregateRootType
and the Id from the provided event
.
Declaration
protected virtual string GenerateStreamName(Type aggregateRootType, IEvent<TAuthenticationToken> event)
Parameters
Type | Name | Description |
---|---|---|
System.Type | aggregateRootType | The System.Type of the IAggregateRoot<TAuthenticationToken>. |
IEvent<TAuthenticationToken> | event | The IEvent<TAuthenticationToken> to extract information from. |
Returns
Type | Description |
---|---|
System.String |
GenerateStreamName(Type, Guid)
Generate a unique stream name based on the provided aggregateRootType
and the aggregateId
.
Declaration
protected virtual string GenerateStreamName(Type aggregateRootType, Guid aggregateId)
Parameters
Type | Name | Description |
---|---|---|
System.Type | aggregateRootType | The System.Type of the IAggregateRoot<TAuthenticationToken>. |
System.Guid | aggregateId | The ID of the IAggregateRoot<TAuthenticationToken>. |
Returns
Type | Description |
---|---|
System.String |
Get(Guid)
Get all IEvent<TAuthenticationToken> instances for the given correlationId
.
Declaration
public abstract IEnumerable<EventData> Get(Guid correlationId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | correlationId | The CorrelationId of the IEvent<TAuthenticationToken> instances to retrieve. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<EventData> |
Implements
Get(Type, Guid, Boolean, Int32)
Gets a collection of IEvent<TAuthenticationToken> for the IAggregateRoot<TAuthenticationToken> of type aggregateRootType
with the ID matching the provided aggregateId
.
Declaration
public abstract IEnumerable<IEvent<TAuthenticationToken>> Get(Type aggregateRootType, Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Type | aggregateRootType | System.Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in. |
System.Guid | aggregateId | The Id of the IAggregateRoot<TAuthenticationToken>. |
System.Boolean | useLastEventOnly | Loads only the last eventIEvent<TAuthenticationToken>. |
System.Int32 | fromVersion | Load events starting from this version |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>> |
Implements
Get<T>(Guid, Boolean, Int32)
Gets a collection of IEvent<TAuthenticationToken> for the T
with the ID matching the provided aggregateId
.
Declaration
public virtual IEnumerable<IEvent<TAuthenticationToken>> Get<T>(Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | aggregateId | The Id of the IAggregateRoot<TAuthenticationToken>. |
System.Boolean | useLastEventOnly | Loads only the last eventIEvent<TAuthenticationToken>. |
System.Int32 | fromVersion | Load events starting from this version |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEvent<TAuthenticationToken>> |
Type Parameters
Name | Description |
---|---|
T | The System.Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in. |
Implements
PersistEvent(EventData)
Persist the provided eventData
into storage.
Declaration
protected abstract void PersistEvent(EventData eventData)
Parameters
Type | Name | Description |
---|---|---|
EventData | eventData | The EventData to persist. |
Save(Type, IEvent<TAuthenticationToken>)
Saves the provided event
.
Declaration
public virtual void Save(Type aggregateRootType, IEvent<TAuthenticationToken> event)
Parameters
Type | Name | Description |
---|---|---|
System.Type | aggregateRootType | System.Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in. |
IEvent<TAuthenticationToken> | event | The IEvent<TAuthenticationToken> to be saved. |
Implements
Save<T>(IEvent<TAuthenticationToken>)
Saves the provided event
.
Declaration
public virtual void Save<T>(IEvent<TAuthenticationToken> event)
Parameters
Type | Name | Description |
---|---|---|
IEvent<TAuthenticationToken> | event | The IEvent<TAuthenticationToken> to be saved. |
Type Parameters
Name | Description |
---|---|
T | The System.Type of the IAggregateRoot<TAuthenticationToken> the IEvent<TAuthenticationToken> was raised in. |