SmartObject Associations - Enumerating in ASPX

  • 22 April 2008
  • 3 replies
  • 0 views

Badge +2

Hi,


 I have created the following SmartObjects:


Customer(CustomerID, Name,  Surname, ...) and Account(CustomerID, AccountID, AccountNumber, Date....)


I have associated them together on the CustomerID field in a 1 Customer to Many Account relationship.


My problem comes, when in ASPX, I attempt to enumerate all the associations of the SmartObjects.


I can pick up the SmartObjects with no problem.


When I run the following code, I only get associations for the Account SO:


SmartObject so = soServer.GetSmartObject(smartObject);


for (int i = 0; i < so.Associations.Count; i++)
              {
                    Listbox1.Items.Add(so.Associations.SmartObject.Name);


                    for (int j = 0; j < so.Associations.AssociatedProperties.Count; j++)
                    {
                        Listbox1.Items.Add(so.Associations.AssociatedProperties.Name + " <-> " +
                            so.Associations.AssociatedProperties.MapTo + " ( " +
                            so.Associations.SoName + " ) ");
                    }


                }


 


I think this happens because of the way the association is stored in the database.


The table SmartBroker.dbo.Associations has the following fields (the important ones only):


SmartObjectName: Account


RefSmartObjectName: Customer


AssociationType: onetomany


 


My guess is that the associations are only loaded on the SmartObject field and not the RefSmartObject (using the GUID, not the physical name).


I need to be able to follow all associations in both directions but I'm not sure if it is possible.


Any suggestions?


 Thanks


Mike


 


3 replies

Badge +8
Hey Mike,
Did you figure it out ? please share
Badge +2

Hi,


I have not had a chance to look at it but I will be taking a trip to the K2 offices soon to make sure I have the latest K2 binaries and code. If it still does not work, I will ask the K2 guys.

Badge +2
I just tried again with K2 for Visual Studio 4.7285.1.0 and still no joy. I'm not sure what the actual latest version is though.

Reply