Accessing Children BOs from a Parent BO Programmatically


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

I have what seems to be a very simple scenario, but for whatever reason can't get it to work correctly.

I defined parent/child relationship between 2 BOs; 1) setup ParentRelationShip property in BO designer by PK_Id to FK_Id and 2) Dropped 2 objects on the form and set ParentObject property.

I want to loop through parent objects and inner loop children of each parent. But I am getting all "Children" objects for each parent, instead of true children as defined by IDs. What am I missing?

Also is there way to get strongly typed Child object from parent instead of: parentBO.ChildBusinessObjects[0];

here's relevant code:

private void PopulateFactSheets()
{
FillFactSheetsObjects();
if (factSheetCategory.MoveFirst())
{
do
{
TreeNode fsTypeNode = trvFactSheets.Nodes.Add(factSheetCategory.FactSheetType);
FactSheetReport fsR = (FactSheetReport)factSheetCategory.ChildBusinessObjects[0];//can I get to strongly typed child?
if (fsR.MoveFirst())
{
do
{
fsTypeNode.Nodes.Add(fsR.IndexName);
} while (fsR.MoveNext());
}
} while (factSheetCategory.MoveNext());
}
}
private void FillFactSheetsObjects()
{
SqlCommand sqlCmnd = new SqlCommand(SqlCommands.SelectAllFactSheets + ";" + SqlCommands.SelectFactSheetTypes);
BusinessLayer.FillMultipleDataTables(sqlCmnd, factSheetReport, factSheetCategory);
// factSheetReport.ParentBusinessObject = factSheetCategory; //it's set in the designer
}

Thank you for your help.


Reply
Alex Luyando
Alex Luyando
StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)StrataFrame User (298 reputation)
Group: StrataFrame Users
Posts: 112, Visits: 1.2K
Hi Dustin -



I will re-read the post shortly. I think my question was more along the lines of given that at times it is more efficient to make many, smaller trips to the back end, it seems odd that with all of the properties already set between the parent and child business objects that the framework doesn't provide an option for having the child BOs requery on a change to the parent's row (or at least to the related FK value) without the developer handling the fill. Just seems like the hooks are all in place to make this a framework-provided feature and eliminate the need for the developer to roll similar code many times.



My question is probably more a result of my work in the Visual FoxExpress framework, rather than VFP specifically. That said I do find both frameworks similar in many respects, so that will drive additional questions of this nature. Smile



Thanks!

________________
_____/ Regards,
____/ al
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