FieldManager.UpdateChildren calls in Parent-Child-GrandChild

FieldManager.UpdateChildren calls in Parent-Child-GrandChild

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


swegele posted on Saturday, February 22, 2014

I see in ProjectTracker...the ProjectEdit calls FieldManager.UpdateChildren(this)

This hits framework code in the listbase which loops through calling Update/Insert/Delete on its children.

If I have another level deeper...

1.  Do I have to also call FieldManager.UpdateChildren(this)? It doesn't seem like this recurses past the first level in the graph right?

2.  Would it be a good habit to call that at the end of each dataportal insert/update just in case some other developer adds a child property and doesn't know CSLA enough to add that...but they would probably copy it if they were just making their own grandchild from my example.  Not much of a performance hit.

Thanks,

JonnyBee replied on Saturday, February 22, 2014

Hi,

1. yes - this call only goes one level down. So you must add a new one in the child level to process "grandchildren".

2. I have often seen the need to supply an extra parameter (f.ex ParentId) in the UpdateChildren call. IE: You can send multiple extra parameters on the DataPortal.UpdateCild/FieldManager.UpdateChildren and childrens Child_Insert/Child_Update/Child_Delete methods must all have these parameters. So I have never added this as a "default" coding standard in my code. 

IE: Will new children always know the parent id (or maybe the parent is also a new object an has no parenid until is is saved)? 

Copyright (c) Marimer LLC