Getting "Invalid for root objects - use Delete instead for " while Remove for Root BusinessListBase

Getting "Invalid for root objects - use Delete instead for " while Remove for Root BusinessListBase

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


GeorgeG posted on Friday, February 02, 2007

I have a Root BusinessListBase. I add a root BusListBase with a button with this code 

sodCustomersBindingSource.AddNew();
and have this overide
 protected override object AddNewCore() {
          SODCustomer item = SODCustomer.NewSODCustomer();
            Add( item );
            return item;
        }

when I try to remove it
this.sodCustomersBindingSource.RemoveCurrent();

get the error Invalid for root objects - use Delete instead for
the current row is IsNew state

What am I missing?

 

 

ajj3085 replied on Monday, February 05, 2007

Is SODCustomer calling MarkAsChild in its constructor?

GeorgeG replied on Monday, February 05, 2007

No, it is not MarkedAsChild since it is a root BusinessListBase. Have changed it from BusinessListBase to EditableRootListBase and evrything looks to be ok. Of course every row needs to be saved in the db but that is fine with us.

Thanks

ajj3085 replied on Monday, February 05, 2007

Hmm... I think there's some confusion.

The collection you say is a root object.  By definition, the objects contained within the collection are child objects (which is a different relationship than the parent child relationship).

If you have whatever class is stored in the collection call the markaschild method, you can save the entire collection within a transaction.

Now if the objects in the collection are root objects (that is, they can be saved, updated and deleted in their own transaction), then you made the correct choice in use ERLB to hold those objects.

GeorgeG replied on Tuesday, February 06, 2007

This clears things up for me. Thanks

Copyright (c) Marimer LLC