Class AggregateRoot
Base class for event-sourced aggregates with string keys.
public abstract class AggregateRoot : AggregateRoot<string>, IAggregateRoot<string>, IAggregateRoot, IAggregateSnapshotSupport
- Inheritance
-
AggregateRoot
- Implements
- Derived
- Inherited Members
Examples
public class OrderAggregate : AggregateRoot
{
protected override bool ApplyEventInternal(IDomainEvent @event) => @event switch
{
OrderCreated e => Apply(e),
OrderShipped e => Apply(e),
_ => false
};
}
Remarks
This is an alias for AggregateRoot<TKey> with string as the key type.
Use this for aggregates with string identifiers (the most common case).
Constructors
AggregateRoot()
Initializes a new instance of the AggregateRoot class.
protected AggregateRoot()
AggregateRoot(string)
Initializes a new instance of the AggregateRoot class with an identifier.
protected AggregateRoot(string id)
Parameters
idstringThe unique identifier of the aggregate.