DKNet

Represent a soft deletion in the domain

Part of DKNet.EfCore.Abstractions. Implement ISoftDeletableEntity when deletion records a flag, user and time instead of removing the object.

Use the console-project setup in the Quick Start, then replace Program.cs with this example.

using DKNet.EfCore.Abstractions.Entities;
using FluentResults;

var document = new Document();
document.Delete("alice");
Console.WriteLine(document.IsDeleted); // True

public sealed class Document : Entity, ISoftDeletableEntity
{
    public bool IsDeleted { get; private set; }
    public DateTimeOffset? DeletedOn { get; private set; }
    public string? DeletedBy { get; private set; }
    public IResultBase Delete(string user, DateTimeOffset? deletedOn = null)
    {
        IsDeleted = true;
        DeletedBy = user;
        DeletedOn = deletedOn ?? DateTimeOffset.UtcNow;
        return Result.Ok();
    }
}

Document.Delete sets IsDeleted, DeletedBy and DeletedOn and returns a FluentResults result.

The interface declares the fields and Delete contract; your method decides whether deletion succeeds. DeletedBy carries [MaxLength(250)] on the interface.

⚙️ Configuration reference

Argument Type Default Effect
deletedOn DateTimeOffset? null Your implementation decides how to handle an omitted time.

🧱 Where it fits

The domain decides whether deletion is allowed and records the deletion state. The host must supply filtering and save behavior; implementing this interface alone installs neither.

The package component map shows the host, contracts and consumers involved in this capability.

⚠️ Gotchas & limits