Class Aggregate<TKey, TEvent>
Represents the base class from which all implementations of an Aggregate Root (as specified in Domain Driven Design) should derive.
public abstract class Aggregate<TKey, TEvent> : Entity<TKey>, IEntity<TKey>, IIdentity<TKey>, IMetadata
Type Parameters
TKeyThe type of the key that uniquely identifies this aggregate.
TEventThe type of the event that implements the IDomainEvent interface.
- Inheritance
-
objectEntity<TKey>Aggregate<TKey, TEvent>
- Derived
- Inherited Members
- Extension Methods
Constructors
Aggregate(IMetadata)
Initializes a new instance of the Aggregate<TKey, TEvent> class.
protected Aggregate(IMetadata metadata = null)
Parameters
metadataIMetadataThe optional metadata to merge with this instance.
Aggregate(TKey)
Initializes a new instance of the Aggregate<TKey, TEvent> class.
protected Aggregate(TKey id)
Parameters
idTKeyThe identifier of the entity.
Properties
Events
Gets the events that was added to the Aggregate.
public IReadOnlyList<TEvent> Events { get; }
Property Value
- IReadOnlyList<TEvent>
The events added to the Aggregate.
Metadata
Gets the associated metadata of this Aggregate.
public IMetadataDictionary Metadata { get; }
Property Value
- IMetadataDictionary
The associated metadata of this Aggregate.
Methods
AddEvent(TEvent)
Adds an event to the Aggregate.
protected virtual void AddEvent(TEvent e)
Parameters
eTEventThe event to be added to the end of Events.
RemoveAllEvents()
Removes all events from the Aggregate.
public void RemoveAllEvents()
See Also
Entity<TKey>