Skip to main content

Definition

Assembly: CloudNimble.EasyAF.Core.dll Namespace: CloudNimble.EasyAF.Core Inheritance: CloudNimble.EasyAF.Core.EasyObservableObject

Syntax

CloudNimble.EasyAF.Core.DbObservableObject

Summary

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

Remarks

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

Constructors

.ctor

Syntax

public DbObservableObject()

.ctor Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Initializes a new instance of the EasyObservableObject class.

Syntax

public EasyObservableObject()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

IsChanged

Specifies whether or not the object has changed.

Syntax

public bool IsChanged { get; set; }

Property Value

Type: bool

Remarks

Setting this manually allows you to override the default behavior in case your app needs it.

IsGraphChanged

Syntax

public bool IsGraphChanged { get; }

Property Value

Type: bool

OriginalValues

Syntax

public System.Collections.Generic.Dictionary<string, object> OriginalValues { get; private set; }

Property Value

Type: System.Collections.Generic.Dictionary<string, object>

PropertyChangedHandler Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Provides access to the PropertyChanged event handler to derived classes.

Syntax

protected internal System.ComponentModel.PropertyChangedEventHandler PropertyChangedHandler { get; }

Property Value

Type: System.ComponentModel.PropertyChangedEventHandler

ShouldTrackChanges

Specifies whether or not property value changes should be tracked.

Syntax

public bool ShouldTrackChanges { get; internal set; }

Property Value

Type: bool

Remarks

To track changes, call Boolean). PropertyChanged events will still be fired, regardless of this setting.

Methods

AcceptChanges

Clears the DbObservableObject.OriginalValues list and sets DbObservableObject.IsChanged to false.

Syntax

public void AcceptChanges()

AcceptChanges

Clears the DbObservableObject.OriginalValues list and sets DbObservableObject.IsChanged to false, and optionally traverses the object graph to call DbObservableObject.AcceptChanges on any children.

Syntax

public void AcceptChanges(bool goDeep)

Parameters

NameTypeDescription
goDeepbool-

ClearRelationships

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

Syntax

public void ClearRelationships()

Remarks

This is typically used to clean an entity before it is POSTed or PUT over an OData API.

Clone Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Creates a deep copy of the current object using JSON serialization.

Syntax

public T Clone<T>() where T : CloudNimble.EasyAF.Core.EasyObservableObject

Returns

Type: T A new instance of type T that is a deep copy of the current object.

Type Parameters

Exceptions

ExceptionDescription
JsonExceptionThrown when the object cannot be serialized or deserialized.

Dispose Inherited Virtual

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Releases the unmanaged resources used by the EasyObservableObject and optionally releases the managed resources.

Syntax

protected internal virtual void Dispose(bool disposing)

Parameters

NameTypeDescription
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.

Dispose Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Syntax

public void Dispose()

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetRelatedEntityCollectionProperties

Syntax

public System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> GetRelatedEntityCollectionProperties()

Returns

Type: System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo>

GetRelatedEntityProperties

Syntax

public System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> GetRelatedEntityProperties()

Returns

Type: System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo>

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

RaisePropertyChanged Inherited Virtual

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Raises the PropertyChanged event if needed.

Syntax

protected internal virtual void RaisePropertyChanged(string propertyName = null)

Parameters

NameTypeDescription
propertyNamestringThe name of the property that changed.

Remarks

If the propertyName parameter does not correspond to an existing property on the current class, an exception is thrown in DEBUG configuration only.

RaisePropertyChanged Inherited Virtual

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Raises the PropertyChanged event if needed.

Syntax

protected internal virtual void RaisePropertyChanged<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression)

Parameters

NameTypeDescription
propertyExpressionSystem.Linq.Expressions.Expression<System.Func<T>>An expression identifying the property that changed.

Type Parameters

  • T - The type of the property that changed.

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

RejectChanges

Loops through the DbObservableObject.OriginalValues list, sets any property that has changed back to the value it had when Boolean) was called, clears the DbObservableObject.OriginalValues list, and sets DbObservableObject.IsChanged to false.

Syntax

public void RejectChanges()

RejectChanges

Syntax

public void RejectChanges(bool goDeep)

Parameters

NameTypeDescription
goDeepbool-

Set Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

Syntax

protected internal void Set<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression, ref T field, T newValue)

Parameters

NameTypeDescription
propertyExpressionSystem.Linq.Expressions.Expression<System.Func<T>>An expression identifying the property that changed.
fieldTThe field storing the property’s value.
newValueTThe property’s value after the change occurred.

Type Parameters

  • T - The type of the property that changed.

Set Inherited Virtual

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

Syntax

protected internal virtual void Set<T>(string propertyName, ref T field, T newValue)

Parameters

NameTypeDescription
propertyNamestringThe name of the property that changed.
fieldTThe field storing the property’s value.
newValueTThe property’s value after the change occurred.

Type Parameters

  • T - The type of the property that changed.

ToDeltaPayload

Loops through the keys in the DbObservableObject.OriginalValues list and returns an ExpandoObject containing JUST the new values for the properties that changed.

Syntax

public System.Dynamic.ExpandoObject ToDeltaPayload(bool deepTracking = false)

Parameters

NameTypeDescription
deepTrackingbool-

Returns

Type: System.Dynamic.ExpandoObject An ExpandoObject containing JUST the new values for the properties that changed.

Remarks

If the object implements IIdentifiable1`, then the payload will always include the ID.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?

TrackChanges

Starts tracking property value changes for every property, optionally activating this behavior for the entire object graph.

Syntax

public void TrackChanges(bool deepTracking = false)

Parameters

NameTypeDescription
deepTrackingboolWhen true, loops recursively through the object graph and calls Boolean) on every object that
inherits from EasyObservableObject.

Events

PropertyChanged Inherited

Inherited from CloudNimble.EasyAF.Core.EasyObservableObject
Occurs when a property value changes.

Syntax

public System.ComponentModel.PropertyChangedEventHandler PropertyChanged
  • System.ComponentModel.INotifyPropertyChanged
  • System.IDisposable
  • System.ComponentModel.IChangeTracking
  • System.ComponentModel.IRevertibleChangeTracking