I've encountered what appears to be a bug with the CancelEdit functionality in a Windows Forms app.
Steps to reproduce:
I've found that when the object is in this state, it has an EditLevel of 0, which is why CancelEdit isn't working. Any exception thrown from the database layer will cause this same behavior. I tested this by calling RAISERROR from the stored proc.
Any workarounds would be appreciated.
That's actually standard behavior.
What happens is this:
If you want different behavior, you'd need to grab a clone of your object graph before the ApplyEdit() call, then catch the exception from Save() and bind the UI to the clone.
Very interesting. Any suggestions for how I can grab the new object instance if I'm using a CslaActionExtender?
I think I'm very close but I keep running into an exception. I'm using CslaActionExtender. I clone the object in the ObjectSaving event. I trap the ErrorEncountered event to handle exceptions from the database server. In that event, I call ResetActionBehaviors using the clone (this is because data bindings are lost when the exception occurs). When I hit the Cancel button, it works fine on the parent, but the child list collection is giving me an edit level mismatch exception.
Copyright (c) Marimer LLC