When Parent.Save() should it apply Save to Children


Author
Message
Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
Hi,



My form has parent object and 2 children objects (all the relationships set correctly, etc)

On parent BO Navigated event I fill children by Parent PK (childBo.FillByParentPK(parentBO.PKID); ).



But there was a problem parentBO.Save was executed (in edit mode); it was only saving parent's changes. I thought .Save on parent should propagate to children?



So, I added:



parentBO.Save();

Child1BO.Save();

Child2BO.Save();





It works now, but I just want to make sure I am doing the right thing.



Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey Leonard.

See if this one helps:

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

Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Leonard,

If you set the ParentBusinessObject = your ParentBO, it should work as long as the IncludeInFormSave for each child BO is also True.

Take a look at the StrataFlix sample which shows this logic by editing 3 BOs and saving all of them in a single call.

If that does not work, you can also check the BO.IsDirty value to do the save for each child, until you figured out what is going on.  And make sure you are using the latest version 1.6.6.

Edhy Rijo

Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
Hi,



I set all children's IncludeInFormSave property to true. So now in Save method, I am calling .Save on the form (this.Save() ) instead of on parent object, so is that correct approach?
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Yep, that will ceratinly work since calling the save on the form just calls the save on each business object that is a member of that form.

However, just to clear up some confusion, calling the save on the parent will not automatically save the child. It will propogate the parent's new PK (if there is a new PK) to the child's foreign key field so that when it is saved everything will line up correctly.

If you call the save on the child, it will call the save on the parent if the parent IsDirty. So if you modify an existing parent record, or if you are working in a new parent record (the record will be dirty until it is saved the first time) then it will automatically call the save, otherwise it won't since it doesn't need to.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search