DomainEvent
Base class for domain events with MediatR integration.
Interface: IDomainEvent
| Property | Type | Description |
|---|---|---|
| Id | Guid | Unique event identifier |
| OccurredOn | DateTime | When the event occurred |
DomainEvent Class
Abstract base class that auto-generates Id and OccurredOn.
Usage
csharp
public record OrderCompletedEvent(Guid OrderId) : DomainEvent;public record UserRegisteredEvent( Guid UserId, string Email ) : DomainEvent;
Event Handling
csharp
public class OrderCompletedEventHandler : INotificationHandler<OrderCompletedEvent>
{
public async Task Handle(OrderCompletedEvent notification, CancellationToken ct)
{
// Send email, update analytics, etc.
}
}Dispatch
Events are dispatched by infrastructure after SaveChanges.