# Detecting changed properties

**URL:** <https://forum.radzen.com/t/detecting-changed-properties/413>\
**Category:** Angular\
**Created:** [July 13, 2018, 4:17pm UTC](https://forum.radzen.com/t/detecting-changed-properties/413 "2018-07-13T16:17:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![semafox](https://forum.radzen.com/user_avatar/forum.radzen.com/semafox/32/55_2.png) [@semafox](https://forum.radzen.com/u/semafox)\
**Post date:** [July 13, 2018, 4:17pm UTC](https://forum.radzen.com/t/detecting-changed-properties/413/1 "2018-07-13T16:17:23Z")

</div>

I need to detect if a specific object property has changed in my OnXxxUpdated() partial method: what would be the best way to do this?

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [July 13, 2018, 8:43pm UTC](https://forum.radzen.com/t/detecting-changed-properties/413/2 "2018-07-13T20:43:59Z")

</div>

Hi @semafox,

The easiest way is probably to get the existing item from the DB and compare it to the updated one:

```auto
var existing = this.context.Categories.Where(o => o.CategoryID == item.CategoryID).FirstOrDefault();

if (existing.SomeProperty != item.SomeProperty)
{
   // SomeProperty has changed
}

```

---

<div class="post-metadata">

**Author:** ![semafox](https://forum.radzen.com/user_avatar/forum.radzen.com/semafox/32/55_2.png) [@semafox](https://forum.radzen.com/u/semafox)\
**Post date:** [July 13, 2018, 9:14pm UTC](https://forum.radzen.com/t/detecting-changed-properties/413/3 "2018-07-13T21:14:07Z")

</div>

This is how how I was trying to do it, but the values of the properties in **existing** and in **item** were the same…

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [July 14, 2018, 7:48am UTC](https://forum.radzen.com/t/detecting-changed-properties/413/4 "2018-07-14T07:48:38Z")

</div>

Hi @semafox,

Indeed it seems that the EF context [returns the updated entity](https://docs.microsoft.com/en-us/ef/core/querying/tracking) without going to the DB in this case. If you use AsNoTracking() it should work though:

```auto
Step oldStep = this.context.Steps.AsNoTracking().Where(x => x.StepID == item.StepID).FirstOrDefault();

```
