> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# DbObservableObject

> A base class for Entity Framework objects to implement [INotifyPropertyChanged](https://learn.microsoft.com/dotnet/api/system.componentmodel.inotifypropertyc...

## Definition

**Assembly:** CloudNimble.EasyAF.Core.dll

**Namespace:** CloudNimble.EasyAF.Core

**Inheritance:** CloudNimble.EasyAF.Core.EasyObservableObject

## Syntax

```csharp theme={"dark"}
CloudNimble.EasyAF.Core.DbObservableObject
```

## Summary

A base class for Entity Framework objects to implement [INotifyPropertyChanged](https://learn.microsoft.com/dotnet/api/system.componentmodel.inotifypropertychanged), [IChangeTracking](https://learn.microsoft.com/dotnet/api/system.componentmodel.ichangetracking),
and [IRevertibleChangeTracking](https://learn.microsoft.com/dotnet/api/system.componentmodel.irevertiblechangetracking) in front-end development.

## Remarks

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

## Constructors

### &#x20;.ctor

#### Syntax

```csharp theme={"dark"}
public DbObservableObject()
```

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Initializes a new instance of the [EasyObservableObject](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject) class.

#### Syntax

```csharp theme={"dark"}
public EasyObservableObject()
```

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### &#x20;IsChanged

Specifies whether or not the object has changed.

#### Syntax

```csharp theme={"dark"}
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.

### &#x20;IsGraphChanged

#### Syntax

```csharp theme={"dark"}
public bool IsGraphChanged { get; }
```

#### Property Value

Type: `bool`

### &#x20;OriginalValues

#### Syntax

```csharp theme={"dark"}
public System.Collections.Generic.Dictionary<string, object> OriginalValues { get; }
```

#### Property Value

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

### &#x20;PropertyChangedHandler Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Provides access to the PropertyChanged event handler to derived classes.

#### Syntax

```csharp theme={"dark"}
protected internal System.ComponentModel.PropertyChangedEventHandler PropertyChangedHandler { get; }
```

#### Property Value

Type: `System.ComponentModel.PropertyChangedEventHandler`

### &#x20;ShouldTrackChanges

Specifies whether or not property value changes should be tracked.

#### Syntax

```csharp theme={"dark"}
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

### &#x20;AcceptChanges

Clears the [DbObservableObject.OriginalValues](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list and sets [DbObservableObject.IsChanged](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#ischanged) to [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

#### Syntax

```csharp theme={"dark"}
public void AcceptChanges()
```

### &#x20;AcceptChanges

Clears the [DbObservableObject.OriginalValues](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list and sets [DbObservableObject.IsChanged](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#ischanged) to [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), and optionally traverses the object graph to call [DbObservableObject.AcceptChanges](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#acceptchanges) on any children.

#### Syntax

```csharp theme={"dark"}
public void AcceptChanges(bool goDeep)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `goDeep` | `bool` | - |

### &#x20;ClearRelationships

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

#### Syntax

```csharp theme={"dark"}
public void ClearRelationships()
```

#### Remarks

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

### &#x20;Clone Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Creates a deep copy of the current object using JSON serialization.

#### Syntax

```csharp theme={"dark"}
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

* `T` - The type of object to clone. Must inherit from [EasyObservableObject](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject).

#### Exceptions

| Exception | Description |
| - | - |
| `JsonException` | Thrown when the object cannot be serialized or deserialized. |

### &#x20;Dispose Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Releases the unmanaged resources used by the [EasyObservableObject](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject) and optionally releases the managed resources.

#### Syntax

```csharp theme={"dark"}
protected internal virtual void Dispose(bool disposing)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `disposing` | `bool` | true to release both managed and unmanaged resources; false to release only unmanaged resources. |

### &#x20;Dispose Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

#### Syntax

```csharp theme={"dark"}
public void Dispose()
```

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetRelatedEntityCollectionProperties

#### Syntax

```csharp theme={"dark"}
public System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> GetRelatedEntityCollectionProperties()
```

#### Returns

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

### &#x20;GetRelatedEntityProperties

#### Syntax

```csharp theme={"dark"}
public System.Collections.Generic.IEnumerable<System.Reflection.PropertyInfo> GetRelatedEntityProperties()
```

#### Returns

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

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;RaisePropertyChanged Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Raises the PropertyChanged event if needed.

#### Syntax

```csharp theme={"dark"}
protected internal virtual void RaisePropertyChanged(string propertyName = null)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `propertyName` | `string` | The 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.

### &#x20;RaisePropertyChanged Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Raises the PropertyChanged event if needed.

#### Syntax

```csharp theme={"dark"}
protected internal virtual void RaisePropertyChanged<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `propertyExpression` | `System.Linq.Expressions.Expression<System.Func<T>>` | An expression identifying the property that changed. |

#### Type Parameters

* `T` - The type of the property that changed.

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;RejectChanges

Loops through the [DbObservableObject.OriginalValues](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list, sets any property that has changed back to the value it had when `Boolean)` was called,
clears the [DbObservableObject.OriginalValues](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list, and sets [DbObservableObject.IsChanged](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#ischanged) to [`false`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool).

#### Syntax

```csharp theme={"dark"}
public void RejectChanges()
```

### &#x20;RejectChanges

#### Syntax

```csharp theme={"dark"}
public void RejectChanges(bool goDeep)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `goDeep` | `bool` | - |

### &#x20;Set Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

#### Syntax

```csharp theme={"dark"}
protected internal void Set<T>(System.Linq.Expressions.Expression<System.Func<T>> propertyExpression, ref T field, T newValue)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `propertyExpression` | `System.Linq.Expressions.Expression<System.Func<T>>` | An expression identifying the property that changed. |
| `field` | `T` | The field storing the property's value. |
| `newValue` | `T` | The property's value after the change occurred. |

#### Type Parameters

* `T` - The type of the property that changed.

### &#x20;Set Inherited Virtual

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Assigns a new value to the property. Then, raises the PropertyChanged event if needed.

#### Syntax

```csharp theme={"dark"}
protected internal virtual void Set<T>(string propertyName, ref T field, T newValue)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `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. |

#### Type Parameters

* `T` - The type of the property that changed.

### &#x20;ToDeltaPayload

Loops through the keys in the [DbObservableObject.OriginalValues](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list and returns an [ExpandoObject](https://learn.microsoft.com/dotnet/api/system.dynamic.expandoobject) containing JUST the new values for the properties that changed.

#### Syntax

```csharp theme={"dark"}
public System.Dynamic.ExpandoObject ToDeltaPayload(bool deepTracking = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `deepTracking` | `bool` | - |

#### Returns

Type: `System.Dynamic.ExpandoObject`
An [ExpandoObject](https://learn.microsoft.com/dotnet/api/system.dynamic.expandoobject) containing JUST the new values for the properties that changed.

#### Remarks

If the object implements `IIdentifiable`1\`, then the payload will always include the ID.

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

### &#x20;TrackChanges

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

#### Syntax

```csharp theme={"dark"}
public void TrackChanges(bool deepTracking = false)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `deepTracking` | `bool` | When [`true`](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), loops recursively through the object graph and calls `Boolean)` on every object that |
| inherits from [EasyObservableObject](https://easyaf.nimbleapps.cloud/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject). | | |

## Events

### &#x20;PropertyChanged Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`

Occurs when a property value changes.

#### Syntax

```csharp theme={"dark"}
public System.ComponentModel.PropertyChangedEventHandler PropertyChanged
```

## Related APIs

* System.ComponentModel.INotifyPropertyChanged
* System.IDisposable
* System.ComponentModel.IChangeTracking
* System.ComponentModel.IRevertibleChangeTracking


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.