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 IQueryable<T> of event store entities.
Declaration
protected IQueryable<TEventStoreEntity> EventStores { get; }
Property Value
Type | Description |
---|---|
IQueryable<TEventStoreEntity> |
Remarks
This 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)
Adds the new event store entity to the storage, without committing yet.
Declaration
protected override void AddEventStoreEntity(TEventStoreEntity eventStoreEntity)
Parameters
Type | Name | Description |
---|---|---|
TEventStoreEntity | eventStoreEntity | The event store entity to be added. |
Overrides
Remarks
In EF Core this equals to adding the entity to the DbSet
without calling SaveChanges
(that will be called later by the framework).
Find(Expression<Func<TEventStoreEntity, bool>>, 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 |
---|---|---|
Expression<Func<TEventStoreEntity, bool>> | predicate | The predicate applied to get the desired event store. |
DateTime? | snapshot | The optional snapshot datetime. When not |
Returns
Type | Description |
---|---|
TDomainEntity | The domain entity or |
FindAsync(Expression<Func<TEventStoreEntity, bool>>, DateTime?)
Finds the event store matching the specified predicate and if found returns the domain entity after having applied the stored events.
Declaration
public Task<TDomainEntity?> FindAsync(Expression<Func<TEventStoreEntity, bool>> predicate, DateTime? snapshot = null)
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<TEventStoreEntity, bool>> | predicate | The predicate applied to get the desired event store. |
DateTime? | snapshot | The optional snapshot datetime. When not |
Returns
Type | Description |
---|---|
Task<TDomainEntity> | A Task<TResult> representing the asynchronous operation. The task result contains the
domain entity or |
GetEventStoreEntity(TDomainEntity)
Returns the event store entity related to the specified domain entity.
Declaration
protected override TEventStoreEntity? GetEventStoreEntity(TDomainEntity domainEntity)
Parameters
Type | Name | Description |
---|---|---|
TDomainEntity | domainEntity | The domain entity. |
Returns
Type | Description |
---|---|
TEventStoreEntity | The event store entity. |
Overrides
| Improve this doc View sourceGetEventStoreEntityAsync(TDomainEntity)
Returns the event store entity related to the specified domain entity.
Declaration
protected override Task<TEventStoreEntity?> GetEventStoreEntityAsync(TDomainEntity domainEntity)
Parameters
Type | Name | Description |
---|---|---|
TDomainEntity | domainEntity | The domain entity. |
Returns
Type | Description |
---|---|
Task<TEventStoreEntity> | A Task<TResult> representing the asynchronous operation. The task result contains the event store entity. |
Overrides
| Improve this doc View sourceRemoveCore(TEventStoreEntity)
Removes the event store entity and all related events from the store.
Declaration
protected override void RemoveCore(TEventStoreEntity eventStore)
Parameters
Type | Name | Description |
---|---|---|
TEventStoreEntity | eventStore | The entity to be removed. |