Class AggregateRoot
Implements the base class for all aggregate roots. An aggregate forms a tree or graph of object relations. The aggregate root is the top-level container, which speaks for the whole and may delegates down to the rest. It is important because it is the one that the rest of the world communicates with.
public abstract class AggregateRoot
- Inheritance
-
AggregateRoot
- Derived
- Inherited Members
- Extension Methods
Constructors
AggregateRoot()
protected AggregateRoot()
Properties
AggregateIdentifier
Uniquely identifies the aggregate.
public Guid AggregateIdentifier { get; set; }
Property Value
AggregateVersion
Current version of the aggregate.
public int AggregateVersion { get; set; }
Property Value
RootAggregateIdentifier
Uniquely identifies the aggregate.
public Guid RootAggregateIdentifier { get; set; }
Property Value
State
Represents the state (i.e. data/packet) for the aggregate.
public AggregateState State { get; set; }
Property Value
Methods
Apply(IChange)
Applies a change to the aggregate state AND appends the event to the history of uncommited changes.
public void Apply(IChange change)
Parameters
changeIChange
ApplyChange(IChange)
Applies a change to the aggregate state. This method is called internally when rehydrating an aggregate, and you can override this when custom handling is needed.
protected virtual void ApplyChange(IChange change)
Parameters
changeIChange
CreateState()
Every aggregate must override this method to create the object that holds its current state.
public abstract AggregateState CreateState()
Returns
FlushUncommittedChanges()
Returns all uncommitted changes and clears them from the aggregate.
public IChange[] FlushUncommittedChanges()
Returns
- IChange[]
GetUncommittedChanges()
Returns all uncommitted changes.
public IChange[] GetUncommittedChanges()
Returns
- IChange[]
Identify(Guid, Guid)
Assigns a specific organization and user identity to every uncomitted change.
public void Identify(Guid organization, Guid user)
Parameters
LockAndRun(Command, Action)
public void LockAndRun(Command context, Action action)
Parameters
LockAndRun(Action)
public void LockAndRun(Action action)
Parameters
actionAction
Rehydrate(IEnumerable<IChange>)
Loads an aggregate from a stream of events.
public void Rehydrate(IEnumerable<IChange> history)
Parameters
historyIEnumerable<IChange>