Show / Hide Table of Contents

    Class EventSourcingDomainEntity<TKey, TDomainEvent>

    The base class for the domain entities that are persisted in the event store.

    Inheritance
    object
    MessagesSource<TDomainEvent>
    EventSourcingDomainEntity<TKey, TDomainEvent>
    EventSourcingDomainEntity<TKey>
    Implements
    IMessagesSource
    IEventSourcingDomainEntity<TKey>
    IEventSourcingDomainEntity
    Inherited Members
    MessagesSource<TDomainEvent>.GetMessages()
    MessagesSource<TDomainEvent>.ClearMessages()
    MessagesSource<TDomainEvent>.AddEvent(TDomainEvent)
    MessagesSource<TDomainEvent>.AddEvent<TEvent>(bool)
    MessagesSource<TDomainEvent>.RemoveEvent(TDomainEvent)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Domain
    Assembly: Silverback.EventSourcing.dll
    Syntax
    public abstract class EventSourcingDomainEntity<TKey, TDomainEvent> : MessagesSource<TDomainEvent>, IMessagesSource, IEventSourcingDomainEntity<TKey>, IEventSourcingDomainEntity
    Type Parameters
    Name Description
    TKey

    The type of the entity key.

    TDomainEvent

    The base type of the domain events.

    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    Constructors

    | Improve this doc View source

    EventSourcingDomainEntity()

    Initializes a new instance of the EventSourcingDomainEntity<TKey, TDomainEvent> class.

    Declaration
    protected EventSourcingDomainEntity()
    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    | Improve this doc View source

    EventSourcingDomainEntity(IReadOnlyCollection<IEntityEvent>)

    Initializes a new instance of the EventSourcingDomainEntity<TKey, TDomainEvent> class from the stored events.

    Declaration
    protected EventSourcingDomainEntity(IReadOnlyCollection<IEntityEvent> events)
    Parameters
    Type Name Description
    IReadOnlyCollection<IEntityEvent> events

    The stored events to be re-applied to rebuild the entity state.

    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    Properties

    | Improve this doc View source

    DomainEvents

    Gets the domain events that have been added but not yet published.

    Declaration
    [NotMapped]
    public IEnumerable<TDomainEvent> DomainEvents { get; }
    Property Value
    Type Description
    IEnumerable<TDomainEvent>
    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    | Improve this doc View source

    Events

    Gets the events that have been applied to build the current state.

    Declaration
    [NotMapped]
    public IEnumerable<IEntityEvent> Events { get; }
    Property Value
    Type Description
    IEnumerable<IEntityEvent>
    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    | Improve this doc View source

    Id

    Gets the entity identifier.

    Declaration
    public TKey Id { get; protected set; }
    Property Value
    Type Description
    TKey
    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    Methods

    | Improve this doc View source

    AddAndApplyEvent(IEntityEvent)

    Adds the specified event and applies it to update the entity state.

    Declaration
    protected virtual IEntityEvent AddAndApplyEvent(IEntityEvent entityEvent)
    Parameters
    Type Name Description
    IEntityEvent entityEvent

    The event to be added.

    Returns
    Type Description
    IEntityEvent

    The IEntityEvent that was added and applied.

    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    | Improve this doc View source

    GetNewEvents()

    Returns the new events that have to be persisted.

    Declaration
    public IEnumerable<IEntityEvent> GetNewEvents()
    Returns
    Type Description
    IEnumerable<IEntityEvent>

    The new events to be persisted.

    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    | Improve this doc View source

    GetVersion()

    Returns the version of the entity. In the default implementation this is a sequence that is increment every time a new event is applied.

    Declaration
    public int GetVersion()
    Returns
    Type Description
    int

    The entity version.

    Remarks

    It's not mandatory to use this base class as long as long as the domain entities implement the IEventSourcingDomainEntity<TKey> interface.

    Implements

    IMessagesSource
    IEventSourcingDomainEntity<TKey>
    IEventSourcingDomainEntity
    • Improve this doc
    • View source
    In this article
    • Constructors
      • EventSourcingDomainEntity()
      • EventSourcingDomainEntity(IReadOnlyCollection<IEntityEvent>)
    • Properties
      • DomainEvents
      • Events
      • Id
    • Methods
      • AddAndApplyEvent(IEntityEvent)
      • GetNewEvents()
      • GetVersion()
    • Implements
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini