Change Tracking

With entity framework, specifically when you're updating data, you have access to the entity details which allows you to view the entity state and also the old values of properties belonging to that entity. (Ref: https://entityframework.net/knowledge-base/15012621/how-to-get-original-entity-from-changetracker)

In Lightswitch we had access to inserting and updating override methods that allowed us to access what I'm referring to so that we could compare values before committing changes to the database. It seems like in Radzen, the only override methods we have access to are updated and created which is too late to catch the old values.

Is there somewhere in the save pipeline (from submitting the form to updating the database) where I can query the entity state and look at the old properties?

Just found this: Detecting changed properties

Is this still the advised route to do what I wish?

Thanks,
Paul.

1 Like

Hi @Paul_Pitchford,

That answer shows one way to do that. The linked article would also probably work. The partial methods should have access to the EF context which you can use.

I miss the 'before' and 'after' methods in the save pipeline.
In LightSwitch we had:

CreateFoo(foo) {
    Foo_Creating(foo)
    SaveChanges()
    Foo_Created(foo)
    return foo
}


    UpdateFoo(foo) {
        Foo_Updating(foo)
        SaveChanges()
        Foo_Updated(foo)
        return foo
}

Creating, Created, Updating, Updated, Deleting, Deleted were partial methods on every entity so we had full control to extend every step on save pipeline.

That said, in RadZen OnCreated and OnUpdated methods do execute before save, I believe.

save pipline partial methods implented! woot! Thanks @korchev!