Class DomainEvent
Envelope that carries a domain event payload (Event) together with its indexing metadata (EventType and Tags).
public record DomainEvent : IEquatable<DomainEvent>
- Inheritance
-
DomainEvent
- Implements
- Inherited Members
Remarks
You do not need to set EventType manually — when left unassigned it
defaults to the simple class name of the inner Event object
(e.g. "StudentRegisteredEvent"). Override it only when you want to decouple
the stored type name from the CLR class name.
Properties
Event
public required IEvent Event { get; init; }
Property Value
EventType
The event type name used for indexing and querying.
When not set explicitly, defaults to the simple class name of the inner Event
(e.g. "StudentRegisteredEvent"). This makes construction via new DomainEvent { Event = ... }
always produce a valid, consistent type name without any manual assignment.
public string EventType { get; init; }
Property Value
Remarks
You can still set a custom value (e.g. "StudentRegistered" without the suffix)
but it must be consistent between writes (append) and reads (query), because it is
what gets stored in the EventType index. It is intentionally decoupled from the
$type AQN used for polymorphic deserialization, so namespace renames
do not affect query behaviour.
Tags
Tags attached to this event for indexing and querying. Immutable after construction; use IEventStoreMaintenance.AddTagsAsync to add tags retroactively.
public IReadOnlyList<Tag> Tags { get; init; }