11-23-2009 10:37 AM
Hi,
I'm creating an onPropertyChange event, in which I would like to save the value on a separate entity B when a value on entity A changes. The problem is, I write the following code:
invest.Fund = fund.Name;
invest.Save();
And when I run it, it falls into an infinite loop. If I take the save out, it doesn't loop, but it doesn't save either.
Any ideas?
Thanks!
~ Henry
11-24-2009 01:24 PM
Is Invest a child of the fund Entity?
If yes, then configure the Relationship betwen fund and invest to use a Cascade option that includes "Save".
Once configured in this manner - when the fund.Save() occurs, an invest.Save() will automatically happen for any related Invest entities that have been added and/or updated.
Note that this would occur automatically and that you woudl need to *remove* your explicit invest.Save();
I am not certain what the technique is if you are trying to update an Entity that is not related to the current Entity. I had struggled with that myself not long ago but lucked out and decided that a Relationship was actually going to be OK to create in my specific case.