Skip to content

SoftDeletableEntity

Class abstractpublic
Base class for entities that support soft deletion in addition to audit tracking.
Namespace SampleApi
Assembly SampleApi
Package v1.0.0.0
public abstract class SoftDeletableEntity
: SampleApi.AuditableEntity
AuditableEntitySoftDeletableEntity
classDiagram
    direction TB
    class SoftDeletableEntity {
        <<abstract>>
    }
    class AuditableEntity {
        <<abstract>>
    }
    AuditableEntity <|-- SoftDeletableEntity
Entities derived from SoftDeletableEntity are never physically removed from the data store. Instead, the IsDeleted flag is set to true and DeletedAt records the time of deletion. Query logic should filter out soft-deleted entities by default.
DeletedAt Section titled DeletedAt nullable
DateTimeOffset?
DateTimeOffset? SoftDeletableEntity.DeletedAt

Gets or sets the UTC date and time when the entity was soft-deleted.

DeletedBy Section titled DeletedBy nullable
string?
string? SoftDeletableEntity.DeletedBy

Gets or sets the identifier of the user who deleted the entity.

bool SoftDeletableEntity.IsDeleted

Gets or sets a value indicating whether the entity has been soft-deleted.

void SoftDeletableEntity.Restore()

Restores a previously soft-deleted entity, clearing deletion metadata.

void SoftDeletableEntity.SoftDelete(
string? deletedBy = null)

Marks the entity as deleted by setting IsDeleted to true and recording the current UTC time and the identity of the user performing the deletion.

deletedBy string? optional
The identifier of the user performing the deletion.