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.