Table of Contents

Class Entity<TKey>

Namespace
Dynamicweb.Core
Assembly
Dynamicweb.Core.dll
The class Entity provides change tracking for models that needs to be persisted.
[Serializable]
public class Entity<TKey> : IChangeTracking

Type Parameters

TKey
The generic Type parameter TKey indicates the type of key used to identity a given Entity instance
Inheritance
Entity<TKey>
Implements
Inherited Members

Constructors

Entity()

Initializes a new instance of the Entity class
public Entity()

Properties

Audit

Gets the audit of this entity showing who and when this entity was created and/or modified
public AuditedEntity Audit { get; protected set; }

Property Value

AuditedEntity

ID

Gets the unique identification of this entity
public TKey ID { get; protected set; }

Property Value

TKey

IsChanged

Defines if this object has been changed.
protected bool IsChanged { get; }

Property Value

bool

IsDeleted

Gets a value indicating if the Entity has been deleted
public bool IsDeleted { get; }

Property Value

bool

IsModified

Gets a value indicating if the entity has been modified
public bool IsModified { get; }

Property Value

bool

IsNew

Gets a value indicating if this is a new transient object
public bool IsNew { get; }

Property Value

bool

State

Gets the current state of this entity
public EntityState State { get; protected set; }

Property Value

EntityState

Methods

BeginRestoring()

Indicates that restoring of the entity will begin and no change tracking will be performed before EndRestoring has been called
protected void BeginRestoring()

Delete()

Marks the entity as deleted
public virtual void Delete()

EndRestoring()

Indicates that restoring has ended and change tracking should be resumed
protected void EndRestoring()

MarkAsModified()

Marks the Entity instance as modified
protected void MarkAsModified()

SetEnum<TEnum>(string, ref TEnum, TEnum)

Change Tracking method for setting enum values, and determining the new state of the Entity.
protected bool SetEnum<TEnum>(string name, ref TEnum oldValue, TEnum newValue) where TEnum : struct, IConvertible

Parameters

name string
The name of the property on which a value is being set
oldValue TEnum
The old value of the property
newValue TEnum
The new value of the property

Returns

bool
True if the new value was not equal to the old value and the state has been succesfully changed to modified, otherwise false

Type Parameters

TEnum

Exceptions

InvalidOperationException
If the generic type is not of type Enum, the exception will be thrown

SetProperty<T>(string, ref T, T)

Change Tracking method for setting property values, and determining the new state of the Entity.
protected bool SetProperty<T>(string name, ref T oldValue, T newValue) where T : IComparable<T>

Parameters

name string
The name of the property on which a value is being set
oldValue T
The old value of the property
newValue T
The new value of the property

Returns

bool
True if the new value was not equal to the old value has the state has been succesfully changed to modified, otherwise false

Type Parameters

T

SetProperty<T>(string, ref T?, T?)

Change tracking method for setting nullable property values, and determining the new state of the Entity
protected bool SetProperty<T>(string name, ref T? oldValue, T? newValue) where T : struct, IComparable<T>

Parameters

name string
The name of the property on which a value is being set
oldValue T?
The old value of the property
newValue T?
The new value of the property

Returns

bool
True if the new value was not equal to the old value has the state has been succesfully changed to modified, otherwise false

Type Parameters

T
To top