child object and updated id upon insert and expected resultchild object and updated id upon insert and expected result
Old forum URL: forums.lhotka.net/forums/t/5255.aspx
Harry_Seldon posted on Sunday, August 17, 2008
Hi everyone,
I'm not clear on the following expected behaviour.
RootObjectList--->child object
items--->item
I do the following for a new item
Items items = Items.NewItems();
Item item = Item.NewItem();
/* populate some properties etc. */
items.Add(item);
// at this point item.ItemId has a value of zero, which is what I expect
items.Save();
// items gets saved, in item object insert there is the following code
// itemId = (int)cm.Parameters["@NewitemId"].Value;
// which works correctly, if I put a break point here, I will see itemId have the correct value
// that matches the database value
int temp = item.ItemId;
// at this point I expect temp to have the database value.
// but it does not it is still zero.
My question is: is the zero expected behavior or have I gummed something up and the value should be the new value?
Thanks in advance
harry
JoeFallon1 replied on Sunday, August 17, 2008
The answer is almost always this one:
When you saved the BO you just called .Save on it like this:
MyBO.Save
What you need to do to see the returned value is this:
MyBO = MyBo.Save
You have to update your reference in the UI.
Joe
Harry_Seldon replied on Monday, August 18, 2008
Thank you!
Copyright (c) Marimer LLC