This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I would like to detect then a certain property of an object changes, possibly before it changes so that I can be the previous value and the new value and perform certain operation before the change is committed to the database. How can I do that? I need to perform the operation before the object is updated. Thanks. |
|
|
|
|
|
Hi,
Have you seen the Entity.ChangeTracker property, in the help file under LightSpeed > Change Tracking. HTH ps weird its removing the contents of my paste first time (using Chrome) |
|
|
What I did was setting ChangeTracker.TrackingMode = ChangeTrackingMode.ChangesOnly; in the constructor of my object and then subscribing to the PropertyChanged event but if I query the ChangeTracker.Changes I get an empty list Am I doing things correctly? Is there a way to detect a change before it's committed to the object? Thank you. |
|
|
If you want to inspect the state of an object prior to saving it to the database, you can do this anytime up until when you call SaveChanges(), given you want to inspect the previous value you will definitely want to use the ChangeTracker for this. Can you give an example of how you are using the ChangeTracker around not seeing any values in the changes list?
Jeremy |
|
|
At the end I didn't use the ChangeTracker but implemented the property as fieldonly and took care of firing an event when the value of the property changes (and implemented the standard code used for loading and writing data to the database). Don't know if there's a better method to do this. |
|