Saving Children

Saving Children

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


Michael Hildner posted on Friday, June 09, 2006

Hi,

I searched the book and the forum, but couldn't find anything.

I added an EditableChildCollection to my EditableRoot. I successfully added EditableChild items to the collection using .AddNew(). Now I need to save these when I save the EditableRoot.

I was hoping this would be done automatically, but I guess that's not the case. What do I need to do? Should it be similar to cloning and saving as discussed on page 491 in the C# book?

Thanks,

Mike

ajj3085 replied on Friday, June 09, 2006

Usually this is done by having an internal Save method on the child; its the parents job to tell children in collection properties to save.

Andy

Michael Hildner replied on Friday, June 09, 2006

ok, I need to find an example I think. I'm going to search around, but if you know of an example in the book or wherever, please let me know.

Thanks,

Mike

ajj3085 replied on Friday, June 09, 2006

Michael Hildner:

ok, I need to find an example I think. I'm going to search around, but if you know of an example in the book or wherever, please let me know.


In my C# second edition (Csla 2) book, page 426 (Chapter 8, Business Object implementation) there is this line from the code snippit:

// update child objects
_resources.Update( this );

This is in the DataPortal_Insert method for the Project class, so the 'this' is a project instance. 

HTH
Andy

Michael Hildner replied on Friday, June 09, 2006

Thanks Andy, that does help. I've got it working now.

Regards,

Mike

Copyright (c) Marimer LLC