I think that everyone sometime is in the situation to understand which are the difference between two objects.
Sometime it is easy but sometime is not. Imagine that you have to prepare for your user a log of all the difference and changes that has been applied on a complex document object model.
I’m in this situation: I have NHibenrate that maps a database. As usual the principal entity of the domain have dozens and dozens of sub entities.
This complex structure is subject to revision from the user. There is a workflow to generate and approve a newer version of the object graph, but as the graph is complex, the user want to have a report of what is changed. from the last approved version. ok: now I have an graph of objects that represent the current situation, and a graph of objects that represent the last approved version.
How to solve this issue? Next: once you have discovered where the objects differs, you maybe want to see which is the actual value and understand which was the old value and which is the new one. Finally, maybe you want to revert some of the difference…. how you can do it in an efficient and powerful way? the reply is EXPRESSIONS From linq on, .NET have gained one of the best thing I ever seen in a programming language, the ability to manipulate code as it is data.
This possibility is SIMPLY AMAZING. I’ve already used this in SyncWcf and now I’ve another clue that makes me love expression more and more. so what I’ve done? give a look at the code below: More...