Table of Contents

Interface IAggregateRoot

Namespace
Excalibur.Domain.Model
Assembly
Excalibur.Domain.dll

Represents an aggregate root in Domain-Driven Design that uses event sourcing.

public interface IAggregateRoot

Remarks

This interface provides the core event sourcing operations. Snapshot and history replay capabilities are available via IAggregateSnapshotSupport, which aggregates may also implement. Use GetService(Type) to access optional capabilities.

Properties

Id

Gets the unique identifier of the aggregate.

string Id { get; }

Property Value

string

The unique identifier of the aggregate.

Version

Gets the current version of the aggregate.

long Version { get; }

Property Value

long

The current version of the aggregate.

Methods

ApplyEvent(IDomainEvent)

Applies a historical event to rebuild state.

void ApplyEvent(IDomainEvent eventData)

Parameters

eventData IDomainEvent

The event to apply.

GetService(Type)

Gets a service of the specified type from this aggregate.

object? GetService(Type serviceType)

Parameters

serviceType Type

The type of service to retrieve (e.g. IAggregateSnapshotSupport).

Returns

object

The service instance, or null if the service is not supported.

GetUncommittedEvents()

Gets the list of uncommitted events.

IReadOnlyList<IDomainEvent> GetUncommittedEvents()

Returns

IReadOnlyList<IDomainEvent>

The list of uncommitted events.

MarkEventsAsCommitted()

Marks all uncommitted events as committed.

void MarkEventsAsCommitted()