Dear ladies and gents,
I'm trying to determine whether the .NET Framework implements a means
of transactional processing without the need for a database.
Essentially, I'd like to enlist light-weight portable business objects
within transactions so that that have the ability to roll-back if the
client of the object wishes to undo any changes made. For example, if I
had a, let's say for sake of simplicity, a person class that had two
public properties, Forename and Surname. If the user changes both
Forename and Surname then wishes to cancel those changes (meaning that
the object will return to it's original state (before the user modified
the object by means of either of the properties)) they could do by
invoking a method (such as 'Undo').
E.g.
Original values (before user interaction)
============================
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
Then the user modifies the Forename and Surname...
=========================================
personInstance.Forename = "John";
personInstance.Surname = "Smith";
The user then realises that the modifications he/she/it made needs to
be undone, for whatever reason...
The user could then invoke a method such as ...
personInstance.Undo();
The object would then undo all changes made so that all data would
reflect the the object state before the user modified it.
Data after undo...
=============
personInstance.Forename is equal to "Joe"
personInstance.Surname is equal to "Bloggs" (surprise, surprise, I bet
no one saw that coming)...
My current intention is to create deep copies of the object and pass
copies to the clients, let them update the copies and if all is well
(i.e. an undo is not required) then the copy of the object would then
replace the original. Otherwise, the copy object would be discarded
(effectively appearing as an undo operation)...
Please would a kind person, or not so kind (if that is how you prefer
to be perceived) offer some light on whether transactions can be used
quickly and easily to achieve the abovementioned task, or whether my
approach is a bad/good approach/whether there is a better and simpler
way.
Many thanks for taking the time to read this.
Have a nice day,
Craig.