Technology - CSLA 4/Silverlight 4
I have a BO -> BLB -> BO scenario. The UI allows for adding and deleting new BOs to the BLB child list. If I add a new BO, save it (persist it to the DB) and then delete it, it seems to have no problem. However, if I add a new BO, then try to remove it , before persisting it to the DB (before Save), it throws a “Invalid for root objects - use Delete instead” exception.
-> ChildList (BLB)
-> Child (BO)
In my viewmodel, if I do a ChildList.Add(Child object) and follow it up with the same ChildList.Remove(Child Object), it throws the exception. Anything I am missing here? I do notice that the IsNew property is being marked correctly on the newly added object and that seems to be the only difference between this object and the rest of the objects in the BLB.
It sounds like you aren't creating new objects correctly as you add them to the collection, because IsChild isn't being set.
Probably your data portal code uses FetchChild to get the child - but your code to create a new object maybe isn't using CreateChild? Or if you are using much older CSLA versions you'd need to be calling MarkAsChild explicitly.
You were right. I was not adding the children correctly. I did not invoke the AddNew method and was trying to do this.Model.Object.Add(objInstance) directly. Anyway thanks for your direction!
Copyright (c) Marimer LLC