Help with Self-referencing object hierarchy

Help with Self-referencing object hierarchy

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


mswanson posted on Tuesday, April 23, 2013

Hi,

I'm brand new to CSLA and have been making my way through the e-books and the forum.

I have a object hierarchy like the following:  A Circle can reference any number of other Circles and a Circle can reference any number of Squares.  It is not child-parent relationships as circles and squares can exists without each other.  

So far, I created

public class Circle : BusinessBase<Circle>
{
   public string Name {get; set;}
   //public CircleList Circles {get;set;}
}

public class CircleList : BusinessListBase<CircleList, Circle>
{
}

which gave me a start.  But as soon as i uncommented the Circles property in the Circle object, I changed my CircleList to DynamicListBase<Circle>.

In a test, I create two Circles, and add one as a child of the parent.  The DataPortal_Update method is never called, so my Dal is never called to persist the Circles relationship.

Could anyone give me some help on this problem?

Thanks!

JonnyBee replied on Friday, May 03, 2013

Hi,

In order to propagate the save to child objects you should call

FieldManager.UpdateChildren

in your "root" objects DataPortal_Insert / DataPortal_Update. 
This will in turn call Child_Insert / Child_Delete methods in the child objects at the next level.

This is described in the Using Csla4 DataAccess ebook. http://download.lhotka.net/Default.aspx?t=UsingCsla4

Copyright (c) Marimer LLC