StrataFrame Forum

Manually setting relations

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

By Paul Chase - 3/14/2007

I am trying to manually set a relation in the Form's load event as follows but it doesnt seem to work. Any ideas on what I am missing or is this the wrong approach?

Me.BoAddress1.ParentBusinessObject = Me.BoEmployee1

Dim loRelation As New MicroFour.StrataFrame.Business.BusinessParentRelationship

loRelation.ForeignKeyField() = New String() {"Adr_FK_ID"}

loRelation.ParentPrimaryKeyField() = New String() {"EMP_PK"}

loRelation.ParentBusinessObjectType = "PayrollBO.BOEmployee"

'Set the Relationship

Me.BoContacts1.ParentRelationship = loRelation

By Trent L. Taylor - 3/14/2007

More than likely your full name is wrong or cannot be resolved.  The best way to get the exact settings rather than guessing is to use the type editor (builder) to create the relationship for you.  Then go the InitializeComponent method of that BO (it will be in the partial class) and copy out the foreign field, primary field, and BO type and then place it into your code.  You can then go back and reset teh parent relationship so that you can just do it in code.  Compare what you have to what is generated through the type editor to find your problem.
By Paul Chase - 3/14/2007

That is all fine..... I need to spend some more time with it to give you a better idea if the issue but basically what I have is an address table and and address BO. I have created a configurable user control so I can use the same address control thoughout the app to store addresses. I have set the bo translations etc and everything works nice except the relations part. I'll look at it some more and try to give you a better idea of what exactly is going on
By Paul Chase - 3/15/2007

Trent,

I guess it is case sensitive??? Seems like that was the issue.

By Paul Chase - 3/15/2007

I was wrong I forgot to remove the test relation that I set up in the BO to get the code from the designer. Guess I was just over anxious to get this working
By Trent L. Taylor - 3/15/2007

Smile Glad you found your trouble spot and got it working.  I understand, I have been there before!