Table of Contents

Class Entity<TId>

Namespace
Signal.Domain.Entities
Assembly
Signal.Domain.dll

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

TId

The identifier type.

Inheritance
Entity<TId>
Implements
Derived
Inherited Members

Constructors

Entity(TId)

Initializes the entity with its identity.

protected Entity(TId id)

Parameters

id TId

The 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

other Entity<TId>

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

left Entity<TId>

The first entity.

right Entity<TId>

The second entity.

Returns

bool

true if both are null or have the same type and id.

operator !=(Entity<TId>?, Entity<TId>?)

Compares two entities by identity.

public static bool operator !=(Entity<TId>? left, Entity<TId>? right)

Parameters

left Entity<TId>

The first entity.

right Entity<TId>

The second entity.

Returns

bool

true if the entities differ in type or id.