How to update related objects

How to update related objects

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


Khaled posted on Sunday, June 24, 2012

Hello,

I have BB that could have children of the same type, I have property to determine if the current instance is Simple or Complex

and I have Price property

Let me give you this example:

Water (Simple), Sugar (Simple), Milk(Simple), Pie(Complex), Tea(Complex)

Pie contains: Water + Sugar + Milk
Tea contains: Water + Sugar

Breakfast contains: Pie + Tea + Water

so if I open Pie window and edit the Price of sugar, ChildChanged will fired and I will update price of the Pie,

but Breakfast cost will not get updated until I open its window and manually call refresh method which will do all the calculation.

my question is this, can I automate this process as I had a lot of objects and I can't figure what is the best practice to fix this problem.

I am thinking of updating this using linq but I am hoping to find a better more robust solution

 

JonnyBee replied on Sunday, June 24, 2012

Well,

The safest way is to do this within triggers in the database.

If you wish to do this outside the database then I would create CommandObject(s) to do the recalculation and call this from the Update method of the actual BusinessObjects. Remember this will have to be done recursively.

 

Copyright (c) Marimer LLC