> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/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

### <Icon icon="hammer" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> .ctor

#### Syntax

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

### <Icon icon="hammer" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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

#### Syntax

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

### <Icon icon="hammer" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

## Properties

### <Icon icon="tag" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> 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.

### <Icon icon="tag" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> IsGraphChanged

#### Syntax

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

#### Property Value

Type: `bool`

### <Icon icon="tag" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> OriginalValues

#### Syntax

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

#### Property Value

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

### <Icon icon="tag" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> PropertyChangedHandler <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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`

### <Icon icon="tag" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> 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

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> AcceptChanges

Clears the [DbObservableObject.OriginalValues](/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list and sets [DbObservableObject.IsChanged](/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()
```

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> AcceptChanges

Clears the [DbObservableObject.OriginalValues](/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list and sets [DbObservableObject.IsChanged](/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](/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` | -           |

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> 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.

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Clone <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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](/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject).

#### Exceptions

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

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Dispose <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

Releases the unmanaged resources used by the [EasyObservableObject](/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. |

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Dispose <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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

#### Syntax

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

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="thumbtack" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetHashCode <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `int`

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetRelatedEntityCollectionProperties

#### Syntax

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

#### Returns

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

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetRelatedEntityProperties

#### Syntax

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

#### Returns

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

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetType <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `System.Type`

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> MemberwiseClone <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `object`

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> RaisePropertyChanged <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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.

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> RaisePropertyChanged <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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.

### <Icon icon="thumbtack" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> ReferenceEquals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> RejectChanges

Loops through the [DbObservableObject.OriginalValues](/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](/api-reference/CloudNimble/EasyAF/Core/DbObservableObject#originalvalues) list, and sets [DbObservableObject.IsChanged](/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()
```

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> RejectChanges

#### Syntax

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

#### Parameters

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

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Set <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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.

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> Set <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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.

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> ToDeltaPayload

Loops through the keys in the [DbObservableObject.OriginalValues](/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.

### <Icon icon="code-fork" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> ToString <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

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

#### Returns

Type: `string?`

### <Icon icon="function" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> 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](/api-reference/CloudNimble/EasyAF/Core/EasyObservableObject). |        |                                                                                                                                                                                      |

## Events

### <Icon icon="bell" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> PropertyChanged <Badge color="gray">Inherited</Badge>

<Note>Inherited from `CloudNimble.EasyAF.Core.EasyObservableObject`</Note>

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
