Syncing a supporting BO with the primary BO


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I have a BO on my form which uses a few other BOs to get property and the like.  I would like to have properties on my primary BO which point to properties on the secondary BO.  For example if I have a secondary BO called Clients which is linked by the ClientKey on the primary/seconday BO, and want to get the Client Description I would have a property like this:

Public ReadOnly Property ClientDescription as String
  Get
    Return Clients.Description
  End Get
End Property

The question I have is how I keep Clients looking at the right record when I am navigating around in the primary BO.  I fill the Clients BO with all clients in the Fill of the primary BO and I have some code in the Navigated and CurrentDataTableRefilled event handlers to navigate Clients to the correct primary key when the primary BO record changes.  

My problem is that when I get into the Navigated event my Clients.Count is 0.  When it starts the Fill method the Client count is a few hundred, but it clears it out somewhere along the way.  Any idea what I am doing wrong here, or if there is a better way of doing what I'm trying to accomplish?  I can't really use the parent/child relationship here because it doesn't make sense in other areas of the database/code.

Reply
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Aha, using a BBS does make a difference.  Basically, the business object tries to act like a single record, but it has several records inside of it.  So, to make it work with the BBS (which expects a list of objects and a different reference for each object within the list, not just the same object over and over again), we have to create a new instance of the BO, share it's data table with the BO you selected as the BusinessObject for the BBS & set it to the right record, and return that new instance of the BO for each index of an item in the list.  So, the problem is that your root business object that contains the populated child reference is not the actual business object being used by the BBS.  That business object is a different instance of the same business object type and shares its CurrentDataTable with the root business object (they have the same reference), and it has its own internal child business object that isn't populated.

Your best bet would be to change the child business object to a shared variable so that all instances of your primary BO type have the same reference.  Or, you could possibly add the code to populate the child into the Navigated() event of the business object and only bring in the records that match the current primary bo record, but that would greatly increase the number of database queries if you have a lot of parent bo records.  Or, you could move the child business object outside of the parent business object and reference it there.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search