DbObservableObject

A base class for Entity Framework objects to implement , , and in front-end development.

Syntax

public class DbObservableObject : EasyObservableObject, INotifyPropertyChanged, IDisposable, IRevertibleChangeTracking, IChangeTracking

Inheritance

Implements

Constructors

DbObservableObject

public DbObservableObject()

Properties

IsChanged

[JsonIgnore]
public bool IsChanged { get; set; }
Specifies whether or not the object has changed.

Returns

bool

IsGraphChanged

[JsonIgnore]
public bool IsGraphChanged { get; }

Returns

bool

OriginalValues

[JsonIgnore]
public Dictionary<string, object> OriginalValues { get; }

Returns

Dictionary<string, object>

ShouldTrackChanges

[JsonIgnore]
public bool ShouldTrackChanges { get; }
Specifies whether or not property value changes should be tracked.

Returns

bool

Methods

AcceptChanges

public void AcceptChanges()
Clears the list and sets to false.

AcceptChanges

public void AcceptChanges(bool goDeep)
Clears the list and sets to false, and optionally traverses the object graph to call on any children.

Parameters

ClearRelationships

public void ClearRelationships()
Sets any child relationships (0..1:1 or 1:*) to null.

GetRelatedEntityCollectionProperties

public IEnumerable<PropertyInfo> GetRelatedEntityCollectionProperties()

Returns

IEnumerable<PropertyInfo>

GetRelatedEntityProperties

public IEnumerable<PropertyInfo> GetRelatedEntityProperties()

Returns

IEnumerable<PropertyInfo>

RecurseGraphInternal

protected static void RecurseGraphInternal(DbObservableObject obj, Action<DbObservableObject> action, bool goDeep = false, HashSet<DbObservableObject> visited = null)

Parameters

RecurseGraphInternal<T>

protected static IEnumerable<T> RecurseGraphInternal<T>(DbObservableObject obj, Func<DbObservableObject, T> func, bool goDeep = false, HashSet<DbObservableObject> visited = null)

Parameters

Returns

IEnumerable<T>

RejectChanges

public void RejectChanges()
Loops through the list, sets any property that has changed back to the value it had when was called, clears the list, and sets to false.

RejectChanges

public void RejectChanges(bool goDeep)

Parameters

Set<T>

protected override void Set<T>(string propertyName, ref T field, T newValue)
Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

Parameters

  • propertyName string: The name of the property that changed.
  • field T: The field storing the property’s value.
  • newValue T: The property’s value after the change occurred.

ToDeltaPayload

public ExpandoObject ToDeltaPayload(bool deepTracking = false)
Loops through the keys in the list and returns an containing JUST the new values for the properties that changed.

Parameters

  • deepTracking bool:

Returns

ExpandoObject An containing JUST the new values for the properties that changed.

ToDeltaPayloadInternal

protected ExpandoObject ToDeltaPayloadInternal(DbObservableObject obj, bool deepTracking = false)

Parameters

Returns

ExpandoObject

TrackChanges

public void TrackChanges(bool deepTracking = false)
Starts tracking property value changes for every property, optionally activating this behavior for the entire object graph.

Parameters

  • deepTracking bool: When true, loops recursively through the object graph and calls on every object that inherits from .

Remarks

https://stackoverflow.com/questions/2363801/what-would-be-the-best-way-to-implement-change-tracking-on-an-object