Class Entity<TId>
Base class for entities: objects defined by their identity rather than their attributes. Two entities are equal when they have the same runtime type and Id.
public abstract class Entity<TId> : IEquatable<Entity<TId>> where TId : notnull
Type Parameters
TIdThe identifier type.
- Inheritance
-
Entity<TId>
- Implements
-
IEquatable<Entity<TId>>
- Derived
- Inherited Members
Constructors
Entity(TId)
Initializes the entity with its identity.
protected Entity(TId id)
Parameters
idTIdThe identifier.
Properties
Id
The identifier.
public TId Id { get; }
Property Value
- TId
Methods
Equals(Entity<TId>?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Entity<TId>? other)
Parameters
otherEntity<TId>An object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Operators
operator ==(Entity<TId>?, Entity<TId>?)
Compares two entities by identity.
public static bool operator ==(Entity<TId>? left, Entity<TId>? right)
Parameters
Returns
operator !=(Entity<TId>?, Entity<TId>?)
Compares two entities by identity.
public static bool operator !=(Entity<TId>? left, Entity<TId>? right)