Interface IEntity
- Namespace
- Trellis
- Assembly
- Trellis.DomainDrivenDesign.dll
Non-generic interface for all entities in Domain-Driven Design. Provides automatic timestamp tracking — CreatedAt records when the entity was first persisted, and LastModified tracks the most recent change.
public interface IEntity
- Extension Methods
Remarks
Timestamps are managed automatically by the Trellis EF Core interceptor
(EntityTimestampInterceptor) on save:
- CreatedAt is set once when the entity is first added
- LastModified is set on every add or modification
Public setters are provided for EF Core materialization (loading from storage) and data migration scenarios. Domain code should not set these directly — they are infrastructure-managed.
This interface follows the same pattern as IAggregate — a non-generic marker that enables type-safe detection in EF Core interceptors without requiring knowledge of the generic type parameter.
Properties
CreatedAt
Gets or sets the UTC timestamp when this entity was first persisted.
DateTimeOffset CreatedAt { get; set; }
Property Value
- DateTimeOffset
The date and time in UTC when the entity was initially saved to storage. Defaults to
default(DateTimeOffset)for unsaved entities.
Remarks
Set automatically by EntityTimestampInterceptor on EntityState.Added.
Public setter is required for EF Core materialization and data migration.
LastModified
Gets or sets the UTC timestamp of the most recent modification to this entity.
DateTimeOffset LastModified { get; set; }
Property Value
- DateTimeOffset
The date and time in UTC when the entity was last saved (created or updated). Defaults to
default(DateTimeOffset)for unsaved entities.
Remarks
Set automatically by EntityTimestampInterceptor on both
EntityState.Added and EntityState.Modified.
For aggregate roots, this value enables RFC 9110 date-based conditional
requests (If-Modified-Since, If-Unmodified-Since) via RepresentationMetadata.