Shouldn't I be using BeginEdit(), ApplyEdit() and CancelEdit() in a web application if storing my objects in session variables? For example, I have a parent and child. The child is edited and the parent Save is called. The business rules of the parent fail, but yet the child values have already been modified. So what happens is, my form view control still shows the child values that the user entered even though the validation failed at the parent. Isn't there a way to cancel(undo, rollback or whatever) the child objects to their orginal states?
It's just I'm using Rocky's web example as a basis for learning and I don't see him using any undo capabilities. I know, I could just reload the objects, but I want to do as much caching as I can to minimize trips to database.
Any suggestions on what I might be doing wrong?
If you are using a Local data portal proxy, then you should use the same Clone() technique as in the Windows Forms chapter. BeginEdit() really isn't a solution here - because what you need is to get the object graph back to the state it was before trying to save it to the database.
Dim temp As Parent = _parent.Clone()
_parent = temp.Save()
(wrapped in Try..Catch of course)
Copyright (c) Marimer LLC