30 lines
1.1 KiB
C#
30 lines
1.1 KiB
C#
using System;
|
|
using Svrnty.CQRS.Events.Abstractions.EventStore;
|
|
|
|
namespace Svrnty.CQRS.Events.Abstractions.Models;
|
|
|
|
/// <summary>
|
|
/// Base class for correlated events with automatic framework-managed properties.
|
|
/// Inherit from this class to avoid manually specifying EventId, CorrelationId, and OccurredAt.
|
|
/// </summary>
|
|
public abstract record CorrelatedEvent : ICorrelatedEvent
|
|
{
|
|
/// <summary>
|
|
/// Unique identifier for this event instance.
|
|
/// Automatically generated when the event is created.
|
|
/// </summary>
|
|
public string EventId { get; init; } = Guid.NewGuid().ToString();
|
|
|
|
/// <summary>
|
|
/// Correlation ID linking this event to the command that caused it.
|
|
/// Automatically set by the framework after the command handler completes.
|
|
/// </summary>
|
|
public string CorrelationId { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Timestamp when the event occurred.
|
|
/// Automatically set to UTC now when the event is created.
|
|
/// </summary>
|
|
public DateTimeOffset OccurredAt { get; init; } = DateTimeOffset.UtcNow;
|
|
}
|