Class EntityBase
Provides a base class for entities.
Namespace: Umbraco.Cms.Core.Models.Entities
Assembly: Umbraco.Core.dll
Syntax
[DataContract(IsReference = true)]
public abstract class EntityBase : BeingDirtyBase, IRememberBeingDirty, ICanBeDirty, IEntity, IDeepCloneable
Constructors
View SourceEntityBase()
Declaration
protected EntityBase()
Properties
View SourceCanChangeKey
Gets a value indicating whether the Key can be changed after the entity has identity.
Override this to return true for entities where Key is derived from other properties (e.g., file path).
Declaration
protected virtual bool CanChangeKey { get; }
Property Value
| Type | Description |
|---|---|
| bool |
CreateDate
Gets or sets the creation date.
Declaration
[DataMember]
public DateTime CreateDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
DeleteDate
Gets or sets the delete date.
Declaration
[DataMember]
public DateTime? DeleteDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime? |
Remarks
The delete date is null when the entity has not been deleted.
The delete date has a value when the entity instance has been deleted, but this value is transient and not persisted in database (since the entity does not exist anymore).
HasIdentity
Gets a value indicating whether the entity has an identity.
Declaration
public virtual bool HasIdentity { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Not serialized as [DataMember] because it's derived from Id. When Id is deserialized, the setter sets _hasIdentity correctly.
Id
Gets or sets the integer identifier of the entity.
Declaration
[DataMember]
public int Id { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Key
Gets or sets the Guid unique identifier of the entity.
Declaration
[DataMember]
public Guid Key { get; set; }
Property Value
| Type | Description |
|---|---|
| Guid |
UpdateDate
Gets or sets the last update date.
Declaration
[DataMember]
public DateTime UpdateDate { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Methods
View SourceDeepClone()
Creates a deep clone of the current object.
Declaration
public object DeepClone()
Returns
| Type | Description |
|---|---|
| object | A deep clone of the current object. |
Equals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Equals(EntityBase?)
Determines whether the specified EntityBase is equal to this instance.
Declaration
public virtual bool Equals(EntityBase? other)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityBase | other | The EntityBase to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
PerformDeepClone(object)
Used by inheritors to modify the DeepCloning logic
Declaration
protected virtual void PerformDeepClone(object clone)
Parameters
| Type | Name | Description |
|---|---|---|
| object | clone |
ResetIdentity()
Resets the entity identity.
Declaration
public virtual void ResetIdentity()