StrataFrame Forum

.ParentRelationship property (changing programmatically)

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

By Charles Thomas Blankenship - 7/7/2006

Executive Summary:

 

How do I dynamically/programmatically change the .ParentRelationship property on an ASPX codebehind page as it loads?

 

Details:

 

I thought I would be able to populate the ParentRelationship property dynamically using the string that appears after using the builder … unfortunately though, as my accounting teacher stated, “Ignorance is bliss … but only for a time”.

 

 

MailAddr.ParentRelationship = "Person, (iID) <--> (iPersonFK)"

 

MailAddr = "Company Location, (iID) <--> (iCompanyLocationFK)"

 

MailAddr.ParentRelationship = "Courthouse, (iID) <--> (iCourthouseFK)"

 

MailAddr.ParentRelationship = "Employee, (iID) <--> (iEmployeeFK)"

 

MailAddr.ParentRelationship = "Investigator, (iID) <--> (iInvestigatorFK)"

 

Further testing simply served to illustrate the level of my ignorance … not to mention short lived blissfulness.  I soon

discovered that this property is really a reference to an object of the following nature:

 

MicroFour.StrataFrame.Business.BusinessParentRelationship

 

A short hunt through the code brought me to this Public Interface:

 

Namespace Business

 

Public Interface IBusinessParentRelationship

 

#Region " Properties "

        Property ParentBusinessObjectType() As String

        Property ParentPrimaryKeyField() As String()

        Property ForeignKeyField() As String()

#End Region

 

#Region " Methods "

        Function Clone() As IBusinessParentRelationship

#End Region

 

End Interface

 

End Namespace

 


At this point, my ignorance kicked in again and I was hopeful that I could simply assign a string to these properties and

then assign that object to the .ParentRelationship property of the MailingAddress business object.  Silly boy … as

“value of type string cannot be converted to a one dimensional array of string”.  Sigh

 

 

oMailingAddress.ParentBusinessObject = oPerson

 

Dim oPersonMARel As New MicroFour.StrataFrame.Business.BusinessParentRelationship

 

oPersonMARel.ForeignKeyField = "iPersonFK"

oPersonMARel.ParentPrimaryKeyField = "iID"

oPersonMARel.ParentBusinessObjectType = "IMA.BOLibrary.Person"

 

oMailingAddress.ParentRelationship = oPersonMARel

 

Ok, I says to myself … much less confident in my ability to do anything at this point other than poo in my shorts … let’s try this:

 

oMailingAddress.ParentBusinessObject = oPerson

 

Dim oPersonMARel As New MicroFour.StrataFrame.Business.BusinessParentRelationship

 

oPersonMARel.ForeignKeyField(0) = "iPersonFK"

oPersonMARel.ParentPrimaryKeyField(0) = "iID"

oPersonMARel.ParentBusinessObjectType = "IMA.BOLibrary.Person"

 

oMailingAddress.ParentRelationship = oPersonMARel

 

But, alas, no, as it is obvious I don’t know how to deal with one dimensional arrays of type string.

 

So, I fall back to your expertise.  How do I dynamically change the .ParentRelationship property on an ASPX page?

 

 

CT

By Charles Thomas Blankenship - 7/7/2006

How do I dynamically/programmatically change the .ParentRelationship property on an ASPX codebehind page as it loads?

 

Should read:

 

How do I dynamically/programmatically change the .ParentRelationship property of a child business object on an ASPX codebehind page as it loads?

 

Thanks,

 

CT

By StrataFrame Team - 7/8/2006

Oh, CT, you are so close Smile

You only need to change the strings to read like this:

New String() {"Value"}  '-- Creates a new string array with only one element

So, this:

oMailingAddress.ParentBusinessObject = oPerson

 

Dim oPersonMARel As New MicroFour.StrataFrame.Business.BusinessParentRelationship

 

oPersonMARel.ForeignKeyField(0) = "iPersonFK"

oPersonMARel.ParentPrimaryKeyField(0) = "iID"

oPersonMARel.ParentBusinessObjectType = "IMA.BOLibrary.Person"

 

oMailingAddress.ParentRelationship = oPersonMARel

 

Should be this:

 

oMailingAddress.ParentBusinessObject = oPerson

 

Dim oPersonMARel As New MicroFour.StrataFrame.Business.BusinessParentRelationship

 

oPersonMARel.ForeignKeyField(0) = New String() {"iPersonFK"}

oPersonMARel.ParentPrimaryKeyField(0) = New String() {"iID"}

oPersonMARel.ParentBusinessObjectType = "IMA.BOLibrary.Person"

 

oMailingAddress.ParentRelationship = oPersonMARel

By Jim Schepflin - 9/20/2006

Here is a C# example, including use of 2 keys in the relationship:





MicroFour.StrataFrame.Business.BusinessParentRelationship oPersonMARel = new MicroFour.StrataFrame.Business.BusinessParentRelationship();

oPersonMARel .ForeignKeyField = new string[] {"Field1ofKey", "Field2ofKey"};

oPersonMARel .ParentPrimaryKeyField = new string[] { "Field1ofKey", "Field2ofKey" };



oPersonMARel .ParentBusinessObjectType = "IMA.BOLibrary.Person";

oMailingAddress.ParentRelationship = oPersonMARel



oMailingAddress.ParentBusinessObject = oPersonMA





Just may make life a bit easier for next person to do this