Class DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity>
The base class for the event store repositories that persist the events into a database.
Inheritance
Inherited Members
Namespace: Silverback.EventStore
Assembly: Silverback.EventSourcing.dll
Syntax
public abstract class DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity> : EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity> where TDomainEntity : class, IEventSourcingDomainEntity<TKey> where TEventStoreEntity : EventStoreEntity<TEventEntity>, new()
where TEventEntity : class, IEventEntity, new()
Type Parameters
Name | Description |
---|---|
TDomainEntity | The type of the domain entity whose events are stored in this repository. |
TKey | The type of the domain entity key. |
TEventStoreEntity | The type of event store entity being persisted to the underlying storage. |
TEventEntity | The base type of the events that will be associated to the event store entity. |
Constructors
| Improve this doc View sourceDbEventStoreRepository(IDbContext)
Initializes a new instance of the DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity> class.
Declaration
protected DbEventStoreRepository(IDbContext dbContext)
Parameters
Type | Name | Description |
---|---|---|
IDbContext | dbContext | The IDbContext to use as storage. |
Properties
| Improve this doc View sourceEventStores
Gets the System.Linq.IQueryable<T> of event store entities.
Declaration
protected IQueryable<TEventStoreEntity> EventStores { get; }
Property Value
Type | Description |
---|---|
System.Linq.IQueryable<TEventStoreEntity> |
Remarks
This System.Linq.IQueryable<T> is pre-configured to include the events and is meant for read only (changes are not being tracked).
Methods
| Improve this doc View sourceAddEventStoreEntity(TEventStoreEntity)
Declaration
protected override void AddEventStoreEntity(TEventStoreEntity eventStoreEntity)
Parameters
Type | Name | Description |
---|---|---|
TEventStoreEntity | eventStoreEntity |
Overrides
Find(Expression<Func<TEventStoreEntity, Boolean>>, Nullable<DateTime>)
Finds the event store matching the specified predicate and if found returns the domain entity after having applied the stored events.
Declaration
public TDomainEntity Find(Expression<Func<TEventStoreEntity, bool>> predicate, DateTime? snapshot = null)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEventStoreEntity, System.Boolean>> | predicate | The predicate applied to get the desired event store. |
System.Nullable<System.DateTime> | snapshot | The optional snapshot datetime. When not |
Returns
Type | Description |
---|---|
TDomainEntity | The domain entity or |
FindAsync(Expression<Func<TEventStoreEntity, Boolean>>, Nullable<DateTime>)
Finds the event store matching the specified predicate and if found returns the domain entity after having applied the stored events.
Declaration
public async Task<TDomainEntity> FindAsync(Expression<Func<TEventStoreEntity, bool>> predicate, DateTime? snapshot = null)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEventStoreEntity, System.Boolean>> | predicate | The predicate applied to get the desired event store. |
System.Nullable<System.DateTime> | snapshot | The optional snapshot datetime. When not |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TDomainEntity> | A System.Threading.Tasks.Task<TResult> representing the asynchronous operation. The task result contains the
domain entity or |
GetEventStoreEntity(TDomainEntity)
Declaration
protected override TEventStoreEntity GetEventStoreEntity(TDomainEntity domainEntity)
Parameters
Type | Name | Description |
---|---|---|
TDomainEntity | domainEntity |
Returns
Type | Description |
---|---|
TEventStoreEntity |
Overrides
GetEventStoreEntityAsync(TDomainEntity)
Declaration
protected override async Task<TEventStoreEntity> GetEventStoreEntityAsync(TDomainEntity domainEntity)
Parameters
Type | Name | Description |
---|---|---|
TDomainEntity | domainEntity |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TEventStoreEntity> |
Overrides
RemoveCore(TEventStoreEntity)
Declaration
protected override void RemoveCore(TEventStoreEntity eventStore)
Parameters
Type | Name | Description |
---|---|---|
TEventStoreEntity | eventStore |