Class EntityBase<TKey>
Provides a base class for entities with a specified key type.
public abstract class EntityBase<TKey> : IEntity<TKey>, IEntity, IEquatable<IEntity<TKey>>
Type Parameters
TKeyThe type of the key used to uniquely identify the entity.
- Inheritance
-
EntityBase<TKey>
- Implements
-
IEntity<TKey>IEquatable<IEntity<TKey>>
- Derived
- Inherited Members
Remarks
This class implements IEntity<TKey> and provides equality comparison based on the key and type of the entity.
Constructors
EntityBase()
Initializes a new instance of the EntityBase<TKey> class.
protected EntityBase()
Properties
Key
Gets the key that uniquely identifies the entity.
public abstract TKey Key { get; }
Property Value
- TKey
The key that uniquely identifies the entity.
Methods
Equals(IEntity<TKey>?)
Indicates whether the current object is equal to another object of the same type.
public virtual bool Equals(IEntity<TKey>? other)
Parameters
otherIEntity<TKey>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.