CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

BeginEdit for child list throws exception.

Last post 05-13-2008, 12:20 PM by sergeyb. 3 replies.
Sort Posts: Previous Next
  •  05-13-2008, 11:58 AM 23540

    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?


    Maxim Alexeyev
  •  05-13-2008, 12:07 PM 23541 in reply to 23540

    RE: BeginEdit for child list throws exception.

    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

    cid:_2_0648EA840648E85C001BBCB886257279
    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?



  •  05-13-2008, 12:16 PM 23542 in reply to 23541

    Re: 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.


    Maxim Alexeyev
  •  05-13-2008, 12:20 PM 23543 in reply to 23542

    RE: RE: BeginEdit for child list throws exception.

    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

    cid:_2_0648EA840648E85C001BBCB886257279
    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.



View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems