...
In figure 1 we have committed "Sigmund Freud" (1.) to the domain
object, as can be seen in the debugger (3.). We are about to
change the FirstName to "Arnold":
In figure 2 we have written "Arnold" into Dr. Freud's
FirstName (1.), what can be seen in the debugger (3.). We are
about to roll that name change back (2.):
In figure 3 we Rollback() has done its thing (1.) and has
restored Freud's FirstName (2.) by reloading the data that was
committed before – "Sigmund":
Now let's see the contrast to Discard()
. In figure 3 above,
we are about to discard the entire transaction. What will
we get if discard the transaction and try to display Freud's
first name with Console.WriteLine()
? (Next line.) The answer
is this:
This is a very helpful exception. It tells you exactly what the
problem is: "The transaction can no longer be used because it has been
discarded."
...