Edit Level Mismatch in AcceptChanges

Edit Level Mismatch in AcceptChanges

Old forum URL: forums.lhotka.net/forums/t/9455.aspx

t.kehl posted on Monday, August 30, 2010


I have the fallowing object-tree:

Company (EditableRoot)
  |--- BranchList (Childlist)
          |--- Branch  (Child)
          |--- Branch  (Child)
          |--- Branch  (Child)

The Branch-object has a Property Parentbrach which is also of the type Branch (Child)

Now, when I add a new object to the Branchlist and then I set the new Branch as ParentBranch of an exisiting Branch I will get a "Edit Level Mismatch" Exception when I save the Company-Object. This is logical, then the same object exists in the BranchList and as a property (ParentBranch) on a Child-Element of the list. When I save the company-object, CSLA will call AcceptChanges twice on the same object (the first one in the  BranchList and the second one on the Property ParentBranch).
The reason for my situation is the fallowing:
I have a window for editing the Company-object. On this window, there is also a Grid which show the BranchList. In the Grid it is also possible to add a new Branch and set a exisiting branch as a ParentBranch of a existing (or new) Branch. For the source to select a ParentBranch, I use the same List which will be shown in the grid. The reason for this is, that I also can select new added (and currently not saved) branches as ParentBranche. Now, I am searching a way, that CSLA will also save the Property ParentBranch of a Branch - but will not execute AcceptChanges on the objects which are set as ParentBranch.

I hope my goal is clear and anybody can help me :-) - Thank you!

Best Regards, Thomas 

RockfordLhotka replied on Monday, August 30, 2010

The CSLA base classes support object graphs with a specific shape:

BB and BLB provide no support for other graph shapes.

Data binding (especially in Windows Forms, which I assume you are using) imposes a whole other set of requirements. CSLA 4 helps somewhat with these, by enabling multiple bindingsource objects to bind to the same object in some cases. That wasn't possible prior to CSLA 4, because the IEditableObject implementation got confused.

t.kehl replied on Saturday, September 04, 2010

Hi Rocky

Thanks for your answer. I use WPF und MVVM. I have now solved my Problem using this

Best Regards, Thomas


Copyright (c) Marimer LLC