Hi Friends,
I'm new to CSLA and I'm currently working on one of our project done using CSLA. I'm getting the following exception when trying to remove an item from the collection. I tried the Delete method but that is not affecting the collection. Can you please shed some light on how to address this issue?
System.NotSupportedException was caught
Message=Invalid for root objects - use Delete instead
Source=Csla
StackTrace:
at Csla.Core.BusinessBase.DeleteChild()
at Csla.Core.BusinessBase.Csla.Core.IEditableBusinessObject.DeleteChild()
at Csla.BusinessListBase`2.DeleteChild(C child)
at Csla.BusinessListBase`2.RemoveItem(Int32 index)
at System.Collections.ObjectModel.Collection`1.RemoveAt(Int32 index)
Thanks,
Hemant.
When you create the items as they are added to the list, are you using the DataPortal.ChildCreate for DataPortal.ChildFetch? If you're using the non-child versions, Csla marks the object as a root meaning it should have no parent, but if its in a list it must be a child.
Thanks Andy,
Thank you for the direction. I added MarkAsChild for the collection entries and this solved the issue.
That will work, but normally the framework calls it for you provide you use FetchChild instead of Fetch on the DataPortal.
Thank you for the heads up Andy.
Regards,
Hemant.
Copyright (c) Marimer LLC