I have the following object graph:
I need to update ListItemLiterals when data in ListCultures is added, removed or updated to keep them in sync (Ex, when a new culture is associated to the list, all its listitems should provide a new ListItemLiteral to hold a new literal for each listitem). Although it would be a broken business rule if the lists did not match, I do not think this falls in this category because I do not want just to validate that they match, I want to actually modify one based on the other.
I am trying to do this by accessing the root from a child. I read in one of Rocky's answers to a post that there is a new feature in CLSA 4 that allows programmers to access the parent and grandparents by simply calling this.Parent.Parent.etc... I have tried it and can not get higher than the immediate parent collection. Unfortunatly, I can not find more information about it. Please help.
The Parent property returns an IParent, and that interface doesn't have a Parent property. You will need to cast the Parent property to some more detailed type so you can navigate higher.
I found this thread ... and it's exactly what I'm trying,
can you give me a CODE example on how to get the grand-parent ??
was trying like this:
var tester = (SecondFactorCredentials) this.Parent; // tester.Parent <---- Not available, I wanted to get the grandparent of this here!!!
and like this:
var test = (BusinessBase<SecondFactorCredentials>) this.Parent; // test.Parent <---- Not available, I wanted to get the grandparent of this here!!!
The following shows the class hierarchy:
DomainModel ( which extends BusinessBase ) <--- this is the grandparent I'm trying to get hold of using this.Parent.GrandParent
- SecondFactorCredentials which also extends BusinessBase <---- the "father"
- UsernamePasswordCredentials which also extends BusinessBase <--- the "grandchild" and "this" in the code above
"this" in the code, child:
public class UserNamePasswordCredentials : LogOnCredentials<UserNamePasswordCredentials>
public abstract class LogOnCredentials<T> : ExtendedBusinessBase<T>, ILogOnCredentials where T : LogOnCredentials<T>
public class SecondFactorCredentials : LogOnCredentials<SecondFactorCredentials>, IMutuallyExclusiveCredential
public class LogOnProcessManager : ExtendedBusinessBase<LogOnProcessManager>, ILogOnProfileInformation
Like Rocky said...you just cast it to the proper type like this:
CommonMatrixList statusList = ((PickingEditRoot) ((PickingEditPurchaseOrderItem) ((PickingEditPurchaseOrderLineList) target.Parent).Parent).Parent).PoLineStatusList;
Copyright (c) Marimer LLC