Class SqlEventStore<TAuthenticationToken>
A simplified SqlServer based EventStore<TAuthenticationToken> that uses LinqToSql and follows a rigid schema.
Inherited Members
Namespace: Cqrs.Events
Assembly: Cqrs.dll
Syntax
public class SqlEventStore<TAuthenticationToken> : EventStore<TAuthenticationToken>, IEventStore<TAuthenticationToken>
Type Parameters
Name | Description |
---|---|
TAuthenticationToken | The System.Type of the authentication token. |
Constructors
SqlEventStore(IEventBuilder<TAuthenticationToken>, IEventDeserialiser<TAuthenticationToken>, ILogger, IConfigurationManager)
Instantiate a new instance of the SqlEventStore<TAuthenticationToken> class.
Declaration
public SqlEventStore(IEventBuilder<TAuthenticationToken> eventBuilder, IEventDeserialiser<TAuthenticationToken> eventDeserialiser, ILogger logger, IConfigurationManager configurationManager)
Parameters
Type | Name | Description |
---|---|---|
IEventBuilder<TAuthenticationToken> | eventBuilder | |
IEventDeserialiser<TAuthenticationToken> | eventDeserialiser | |
cdmdotnet.Logging.ILogger | logger | |
IConfigurationManager | configurationManager |
Properties
ConfigurationManager
Gets or sets the IConfigurationManager.
Declaration
protected IConfigurationManager ConfigurationManager { get; }
Property Value
Type | Description |
---|---|
IConfigurationManager |
Methods
Add(DataContext, EventData)
Persist the provided data
into SQL Server using the provided dbDataContext
.
Declaration
protected virtual void Add(DataContext dbDataContext, EventData data)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Linq.DataContext | dbDataContext | |
EventData | data |
CreateDbDataContext()
Creates a new System.Data.Linq.DataContext using connection string settings from ConfigurationManager.
Declaration
protected virtual DataContext CreateDbDataContext()
Returns
Type | Description |
---|---|
System.Data.Linq.DataContext |
Get(Guid)
Get all IEvent<TAuthenticationToken> instances for the given correlationId
.
Declaration
public override 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> |
Overrides
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 override 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>> |
Overrides
GetEventStoreTable(DataContext)
Gets the System.Data.Linq.Table<TEntity> of EventData.
Declaration
protected virtual Table<EventData> GetEventStoreTable(DataContext dbDataContext)
Parameters
Type | Name | Description |
---|---|---|
System.Data.Linq.DataContext | dbDataContext | The System.Data.Linq.DataContext to use. |
Returns
Type | Description |
---|---|
System.Data.Linq.Table<EventData> |
PersistEvent(EventData)
Persist the provided eventData
into SQL Server.
Declaration
protected override void PersistEvent(EventData eventData)
Parameters
Type | Name | Description |
---|---|---|
EventData | eventData | The EventData to persist. |