I have an object with children (Receipt and items + other detail lists).
I handle BeginEdit/CancelEdit myself by calling BeginEdit when modal window is opened (WinForms). It works well both for root objects (receipt) and child objects (item). However, now I want to modify one of the detail lists and then either apply all changes in the list or cancel them.
BeginEdit doesn't work for list because it's child list (Exception is thrown).
Practical question is what should I do.
Theoretical is why not to allow call BeginEdit for the child list?
1.
issue begin edit and cancel edit on the root regardless what
part of the object graph is modified.
2.
Root object is the one responsible for cancel (restore previous
state) of the entire object graph. So, if you maintain a separate state
stack of a child object, root object will not be able to properly restore the
child’s object state.
Sergey Barskiy
Senior Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: maxal
[mailto:cslanet@lhotka.net]
Sent: Tuesday, May 13, 2008 1:00 PM
To: Sergey Barskiy
Subject: [CSLA .NET] BeginEdit for child list throws exception.
I have an object with children (Receipt and items + other detail lists).
I handle BeginEdit/CancelEdit myself by calling BeginEdit when modal window
is opened (WinForms). It works well both for root objects (receipt) and
child objects (item). However, now I want to modify one of the detail lists and
then either apply all changes in the list or cancel them.
BeginEdit doesn't work for list because it's child list (Exception is
thrown).
Practical question is what should I do.
Theoretical is why not to allow call BeginEdit for the child list?
Are you saying that when I call BeginEdit/CancelEdit for item of the receipt, which I edit it in modal form, it's also not a good idea, even if it works? It's always happening between parents BeginEdit/CancelEdit calls. And it is looks like overhead to call parent's BeginEdit for that.
Because originally I just relied on binding events to call those methods. And they kind of created separate stack (or rather extension) of states. Later I found that there are too many unnecessary calls and switch to manual.
Correct. The guidelines that I follow based on what I know(which
may not be much :-)), is to call Begin edit on root object only and do this
once after it is loaded initially. In cancel button there is only one
CancelEdit call as well and Begin edit to follow, also on root object only.
Sergey Barskiy
Senior Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: maxal
[mailto:cslanet@lhotka.net]
Sent: Tuesday, May 13, 2008 1:16 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: BeginEdit for child list throws exception.
Are you saying that when I call BeginEdit/CancelEdit for item of the
receipt, which I edit it in modal form, it's also not a good idea, even if it
works? It's always happening between parents BeginEdit/CancelEdit calls. And it
is looks like overhead to call parent's BeginEdit for that.
Because originally I just relied on binding events to call those
methods. And they kind of created separate stack (or rather
extension) of states. Later I found that there are too many unnecessary
calls and switch to manual.
Copyright (c) Marimer LLC