Ok, first, I must reiterate that DO4 is the best thing since sliced bread. It truly is remarkable what you guys have created.

Second, I've read the blog post about AuditLogging. It's great.

What I'd like to do, though, is capture the specific changes that were made to persistent fields. Ideally, I'd like to present a UI that shows the transactions that modified an entity and show the previous and new field values.

I've read the suggestion about using OperationCapturer to do this. Is this the best approach? Could you please provide more guidance on how to do this exactly in a way that is efficient?

Do you plan to provide such an implementation by default at some time soon? Seems like it would be quite useful for most DO4 usages.

Thank you!

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked May 17 '10 at 23:01

ara's gravatar image


One Answer:

> Is this the best approach?

Yes, most likely.

An alternative in WPF/WF applications is usage of DisconnectedState clone containing only the original state:

var clone = ds.Clone();
clone.CancelChanges(); // Haha, here you have the state of ds w/o changes ;)


  • You must know all the moments when you load something new into disconnected state (to clone it again). Pretty easy, if you do this manually: mainly, you should do this on completion of each .Connect() method. But if DS is almost always connected, it must be hard. We'll think about extending its API with corresponding events.

  • You must use different Session to "see" the old state (to which clone will be attached).

> Could you please provide more guidance on how to do this exactly in a way that is efficient?

In simplest case I'd use a dictionary with "Entity.PropertyName" key + some high-level API allowing to access old values (e.g. Entity.GetOriginalProperty(...) extension method complementaty to existing ones). Some issues I see:

  • If it's a reference property, and target is already removed, you should properly handle this.

  • You must think about changes in EntitySets - i.e. they must be tracked by some different API, if this is necessary.

answered May 18 '10 at 19:44

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA