Note able to clear items in a businesslistbase, getting "Invalid for root objects - use Delete instead."

Note able to clear items in a businesslistbase, getting "Invalid for root objects - use Delete instead."

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


confern posted on Tuesday, January 08, 2008

I have three classes

RequestList : ReadOnlyListBase<RequestList, RequestTaskList>
RequestTaskList : BusinessListBase<RequestTaskList, RequestTask>
RequestTask : BusinessBase<RequestTask>

I first load my RequestTaskLists through the RequestList by setting IsReadOnly temoprarily = false.

Later on though, I want to take a specific RequestTaskList and clear it out to refresh it's contents with the new db values.  I'm doing this for a workflow, so that I can keep up to date information.  I have the following code in a refresh method in RequestTaskList

using (SmartSafeDataReader dr = new SmartSafeDataReader(cm.ExecuteReader()))
{
      this.ClearItems();
      while (dr.Read())
            this.Add(new RequestTask(dr)); // Refresh List
}

Unfortunetly, my code is breaking down at the the "this.ClearItems()" line and giving me the "Invalid for root objects - use Delete instead."  Note that if I comment out the ClearItems() line my code is still able to add new RequestTasks to the RequestTaskList object.

Can anyone offer me some assistance in understanding why I'm unable to use the ClearItems() call here?

ajj3085 replied on Tuesday, January 08, 2008

Are you calling MarkAsChild in your RequestTask constructor?

confern replied on Tuesday, January 08, 2008

Thank you.  That solved my problem.

Copyright (c) Marimer LLC