How to access an object after Load has been performed?

Feb 17, 2011 at 11:21 PM

Hi,

I'd like to implement change tracking on my objects, but the issue I'm encountering is that when deserialization occurs, the change tracking picks up all the properties which were set, and I'd like to catch when the load is finished so I can clear the changes which were tracked from deserialization.

I noticed a mention of the "dirty" flag in the Triggers and Interceptors section of the documentation.  It mentions resetting it after a save, which I understand.  I'm just not sure how on load you stop it from getting set to true, due to properties being set on deserialization.  I can think of one idea, which is that the dirty flag is persisted as false and you load the false, but this seems like an order of operations issue.  ie. if its deserialized before another property, it'll still end up being true.  On another note, I don't want to serialize my change tracking properties.

I also tried to hook into the SterlingOperationPerformed event and check for a Load operation, but the problem here is that I have a key and if I try to load the object with the key while in the event handler, it just spawns another call to the event handler, so I'm in a loop and can't ever call the clear change attributes on my object.

Any idea on how I should approach this?

Thanks.

Coordinator
Feb 19, 2011 at 12:49 PM

It's a good question and something that needs to evolve for sure. For now, the solution is to clear the dirty flag in the "before save" trigger. Just between you and me (oh, and everyone else reading this thread) I'm working on an implementation for vNext w here you can pass a predicate that takes the entity and returns an "is dirty" flag. This will allow you to use any type of field for the dirty flag, but also will help in saving because with rich object graphs, it won't resave child entites that aren't dirty any more.

Dec 28, 2011 at 8:17 AM

Any update on this?

I too need to reset the change tracking flags after loading objects.  Right now I am doing it manually after a load, but it would be nice to have an event or some other way to clear a flag after load occurs.