Persistence and rollback, model, C#

322 views Asked by At

I asked a little while ago a question about rollback, I have a new related question that I have an answer to, but would like some input.

So I'm building a persistence ignorant object model and I'm now thinking about roll back. I've looked at how nHibernate manages it, and that suggests that I'll need to have my own implementation on the domain objects if I want to be able to cancel unsaved changes.

So I've seen IEditableObject in ComponentModel which succinctly describes the problem. Microsoft's example that goes along with the description is pretty much what I would have done, they have a private struct which contains the actual data, and when the data is changed the original is saved and a new one is created. That and INotifyPropertyChanged to notify that the object has reset.

Has anyone done anything similar? Can you suggest a better pattern?

1

There are 1 answers

1
Chris Shain On BEST ANSWER

I'd suggest you read some of Rocky Lhotka's stuff on his framework, CSLA.NET: http://www.lhotka.net/. I am not sure I'd recommend actually using it, but he covers things like rollback and business object data consistency quite thoroughly.