namespace Heimdall.Domain.Primitives;
///
/// Base class for all domain entities with a strongly-typed identifier.
///
public abstract class Entity : IEquatable>
where TId : notnull
{
public TId Id { get; protected set; } = default!;
protected Entity(TId id) => Id = id;
protected Entity() { } // EF Core
public override bool Equals(object? obj) =>
obj is Entity other && Id.Equals(other.Id);
public bool Equals(Entity? other) =>
other is not null && Id.Equals(other.Id);
public override int GetHashCode() => Id.GetHashCode();
public static bool operator ==(Entity? left, Entity? right) =>
left is null ? right is null : left.Equals(right);
public static bool operator !=(Entity? left, Entity? right) =>
!(left == right);
}