I have the fallowing situation of Root-Object and Child-Object:
The root-Object Contact contains a ChildList-Property called CommunicationList and a Child-Property called DefaultCommunication. The Object assigned to DefaultCommunication also exist in the CommunicationList.
- CommunicationList (child-list)
- DefaultCommunication (child-object)
Now, when I create a new Child-Entry in CommunicationList like this:
var child = this.CommunicationList.AddNew()
And then assign it also to the Property DefaultCommunication, and change a Property of the Object, which is asignd to DefaultCommunication - when I now save the root-Object Contact, it will run in the fallowing exception:
Can anyone give me a hint, what I am doing wrong - or what I have to do to solve this problem?
I use CSLA.NET 4
Thanks for your help.
Best Regards, Thomas
What UI technology are you using?
Something to do with your UI and data binding is leaving the edit level of one of your objects at a value higher than 1.
If you are using Windows Forms, this is pretty common, and the cause is a failure to properly unbind the object(s) from the bindingsource controls.
I am using WPF.
I think it has to do, that the Communication-Object is saved, when the CommunicationList will be saved and after that one more time when the Property DefaultCommunication will be saved. The same object like the Property DefaultMail has is in the Child-CommunicationList.
WPF by itself doesn't use n-level undo at all. That's good news usually, as it is much simpler than Windows Forms. Things that use undo in WPF include:
If you are using any of these controls, you need to understand how and when the controls call BeginEdit, CancelEdit and ApplyEdit, and you need to make sure every BeginEdit has a matching CancelEdit or ApplyEdit.
I usually only allow my top-level root CslaDataProvider or ViewModel<T> object to have ManageObjectLifetime=true. For child objects I usually either use a different manager, or set ManageObjectLifetime=false before the container gets the child object.
If your problem is datagrid related then I suggest you start with some meditation to calm your mind. Then go to the barber and have them shave your head (so you don't pull out your hair - that's painful). Then block off some quality time to fight with the datagrid and dive into the chaos.
Copyright (c) Marimer LLC