Show / Hide Table of Contents

    Class EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>

    The base class for the event store repositories.

    Inheritance
    object
    EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity>
    DbEventStoreRepository<TDomainEntity, TKey, TEventStoreEntity, TEventEntity>
    Inherited Members
    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 EventStoreRepository<TDomainEntity, TEventStoreEntity, TEventEntity> where TDomainEntity : class, IEventSourcingDomainEntity where TEventStoreEntity : class, IEventStoreEntity<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.

    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.

    Methods

    | Improve this doc View source

    AddEventStoreEntity(TEventStoreEntity)

    Adds the new event store entity to the storage, without committing yet.

    Declaration
    protected abstract void AddEventStoreEntity(TEventStoreEntity eventStoreEntity)
    Parameters
    Type Name Description
    TEventStoreEntity eventStoreEntity

    The event store entity to be added.

    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

    GetDomainEntity(TEventStoreEntity, DateTime?)

    Rebuilds the domain entity applying the stored events.

    Declaration
    protected virtual TDomainEntity GetDomainEntity(TEventStoreEntity eventStoreEntity, DateTime? snapshot = null)
    Parameters
    Type Name Description
    TEventStoreEntity eventStoreEntity

    The event store entity referencing the events to be applied.

    DateTime? snapshot

    The optional datetime of the snapshot to build. Specifying it will cause only the events up to this datetime to be applied.

    Returns
    Type Description
    TDomainEntity

    The domain entity rebuilt from the stored events.

    | Improve this doc View source

    GetEventStoreEntity(TDomainEntity)

    Returns the event store entity related to the specified domain entity.

    Declaration
    protected abstract TEventStoreEntity? GetEventStoreEntity(TDomainEntity domainEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity.

    Returns
    Type Description
    TEventStoreEntity

    The event store entity.

    | Improve this doc View source

    GetEventStoreEntity(TDomainEntity, bool)

    Returns the event store entity related to the specified domain entity.

    Declaration
    protected virtual TEventStoreEntity GetEventStoreEntity(TDomainEntity domainEntity, bool addIfNotFound)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity.

    bool addIfNotFound

    Specifies whether the entity must be created when not found.

    Returns
    Type Description
    TEventStoreEntity

    The event store entity.

    | Improve this doc View source

    GetEventStoreEntityAsync(TDomainEntity)

    Returns the event store entity related to the specified domain entity.

    Declaration
    protected abstract 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.

    | Improve this doc View source

    GetEventStoreEntityAsync(TDomainEntity, bool)

    Returns the event store entity related to the specified domain entity.

    Declaration
    protected virtual Task<TEventStoreEntity> GetEventStoreEntityAsync(TDomainEntity domainEntity, bool addIfNotFound)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity.

    bool addIfNotFound

    Specifies whether the entity must be created when not found.

    Returns
    Type Description
    Task<TEventStoreEntity>

    A Task<TResult> representing the asynchronous operation. The task result contains the event store entity.

    | Improve this doc View source

    MapEvent(TEventEntity)

    Maps the persisted entity back to the IEntityEvent.

    Declaration
    protected virtual IEntityEvent MapEvent(TEventEntity eventEntity)
    Parameters
    Type Name Description
    TEventEntity eventEntity

    The stored event entity to be mapped.

    Returns
    Type Description
    IEntityEvent

    The IEntityEvent.

    | Improve this doc View source

    MapEventEntity(IEntityEvent)

    Maps the IEntityEvent to the related entity being persisted into the underlying storage.

    Declaration
    protected virtual TEventEntity MapEventEntity(IEntityEvent entityEvent)
    Parameters
    Type Name Description
    IEntityEvent entityEvent

    The entity event to be mapped.

    Returns
    Type Description
    TEventEntity

    The entity representing the IEntityEvent.

    | Improve this doc View source

    MapEventStoreEntity(TDomainEntity, TEventStoreEntity)

    Maps the domain entity to the event store entity.

    Declaration
    protected virtual void MapEventStoreEntity(TDomainEntity domainEntity, TEventStoreEntity eventStoreEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity to be mapped.

    TEventStoreEntity eventStoreEntity

    The event store entity to be initialized after the domain entity.

    Remarks

    This method should map the entity keys only. The events are handled automatically.

    | Improve this doc View source

    Remove(TDomainEntity)

    Removes the specified domain entity from the event store.

    Declaration
    public TEventStoreEntity Remove(TDomainEntity domainEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity to be removed.

    Returns
    Type Description
    TEventStoreEntity

    The event store entity that was removed.

    | Improve this doc View source

    RemoveAsync(TDomainEntity)

    Removes the specified domain entity from the event store.

    Declaration
    public Task<TEventStoreEntity> RemoveAsync(TDomainEntity domainEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity to be removed.

    Returns
    Type Description
    Task<TEventStoreEntity>

    A Task<TResult> representing the asynchronous operation. The task result contains the event store entity that was removed.

    | Improve this doc View source

    RemoveCore(TEventStoreEntity)

    Removes the event store entity and all related events from the store.

    Declaration
    protected abstract void RemoveCore(TEventStoreEntity eventStore)
    Parameters
    Type Name Description
    TEventStoreEntity eventStore

    The entity to be removed.

    | Improve this doc View source

    Store(TDomainEntity)

    Stores the specified domain entity into the event store.

    Declaration
    public TEventStoreEntity Store(TDomainEntity domainEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity to be stored.

    Returns
    Type Description
    TEventStoreEntity

    The event store entity that was persisted.

    | Improve this doc View source

    StoreAsync(TDomainEntity)

    Stores the specified domain entity into the event store.

    Declaration
    public Task<TEventStoreEntity> StoreAsync(TDomainEntity domainEntity)
    Parameters
    Type Name Description
    TDomainEntity domainEntity

    The domain entity to be stored.

    Returns
    Type Description
    Task<TEventStoreEntity>

    A Task<TResult> representing the asynchronous operation. The task result contains the event store entity that was persisted.

    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini