UpdateChildren and Singular Child Objects

UpdateChildren and Singular Child Objects

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


Wbmstrmjb posted on Monday, April 13, 2009

I have a root class with an singular editable child bo. The "normal" UpdateChildren calls Update on Lists just fine because the list's update code has the "if IsNew then insert, else update" check for each bo in the list. Calling Update on a singular bo, actually calls update which in the case of a new bo, blows up.

So my question is do you put in the IsNew check directly into the UpdateChildren code on the root for the singular bos?

IanK replied on Tuesday, April 14, 2009

I have quite a number of single child BOs and yes I would run a check in the Update method of the child to see it the IsNew property is set to true/false before deciding to insert or update the database. This would be following same pattern as an update on a child list BO.

One other change I am inclined to do is explicitly call MarkClean on the new method in the singleton child object to avoid inserting empty objects into the database where none of the properties on the child object are set. Once a property is set it will automatically revert to isdirty and needs to be saved.

 

 

Copyright (c) Marimer LLC