Show / Hide Table of Contents

    Class DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity>

    The base class for the event store repositories that persist the events into a database.

    Inheritance
    object
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>
    DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity>
    Inherited Members
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.Store(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.StoreAsync(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.Remove(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.RemoveAsync(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntity(TDomainEntity, bool)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntityAsync(TDomainEntity, bool)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.AddEventStoreEntity(TEventStoreEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntity(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntityAsync(TDomainEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.MapEventStoreEntity(TDomainEntity, TEventStoreEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetDomainEntity(TEventStoreEntity, DateTime?)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.MapEventEntity(IEntityEvent)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.MapEvent(TEventEntity)
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.RemoveCore(TEventStoreEntity)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 source

    DbEventStoreRepository(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 source

    EventStores

    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 source

    AddEventStoreEntity(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
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.AddEventStoreEntity(TEventStoreEntity)
    Remarks

    In EF Core this equals to adding the entity to the DbSet without calling SaveChanges (that will be called later by the framework).

    | Improve this doc View source

    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 null only the events registered until the specified datetime are applied, returning the entity in its state back in that moment.

    Returns
    Type Description
    TDomainEntity

    The domain entity or null if not found.

    | Improve this doc View source

    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 null only the events registered until the specified datetime are applied, returning the entity in its state back in that moment.

    Returns
    Type Description
    Task<TDomainEntity>

    A Task<TResult> representing the asynchronous operation. The task result contains the domain entity or null if not found.

    | Improve this doc View source

    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
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntity(TDomainEntity)
    | Improve this doc View source

    GetEventStoreEntityAsync(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
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.GetEventStoreEntityAsync(TDomainEntity)
    | Improve this doc View source

    RemoveCore(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.

    Overrides
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>.RemoveCore(TEventStoreEntity)
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini