Current situation
I have a WPF application where I use MVVM and NHibernate. I have a master/detail window with a listbox with all my customers, and the selectedItem of the listbox is the object that is being used to display the customerdetails in the detailscreen. In the detailscreen I have an add, edit, delete, save and an undo buttton. Everything works with the binding I've set up.
Problem
But for my undo button I was thinking of making a copy of the original Customer object so when I click the undo button the field will be resetted to the values from the original values. But in my customer object I have an Address object and with a shallow copy the 2 objects will keep the same reference to that object. So when I change a field from the Address object the original Customer address will also be changed. I was thinking of doing a deep copy of my Customer address but I can't make my object serializable (It's not in my control to change the Model objects)
I would simply go back to the database and reload the customer object. That ensures that the data you're displaying is consistent with the data in the database and reduces the risk of concurrency issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With