StrataFrame Forum

Parent BO method that need to access child BO

http://forum.strataframe.net/Topic6904.aspx

By Chan - 2/16/2007

Hi,

I want to create public method to calculate order total in OrderBO. It will sum up line items subtotal by loop thru LineItemsBO datarows. The method will be called before OrderBO.beforesave() event.



My problem is, how could I access child BO - LineItemsBO in OrderBO? I can't set LineItemsBO to ParentBusinessObject property at OrderBO component designer.



Any ideas?



Thank you
By Chan - 2/19/2007

Any feedback on this?

Thank you

By Greg McGuffey - 2/19/2007

Since the OrderBO is the parent of the LineItemBO (many lines items belong to an order), you'd set the parent relationship of LineItemBo to be an OrderBO in the LineItemBO designer. Then when using instances of these, you'd set the parent BO of a line item to the specific instance of the OrderBO. However, I pretty sure there isn't a way to set a child BO in the parent. However, you could create a custom property in the OrderBO:





Private _itemsBO as LineItemBO

Public Property ItemsBO() As LineItemBO

Get

Return _itemsBO

End Get

Set(value as LineItemBO)

_itemsBO

End Set

End Property



This should show up on the properties window of your BO. Then you can set it and use it in your method. I hope I've understood the problem and that this is helpful.