Multiple BO instances with a BBS


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
In a recent email conversation with Trent, he told me that a BBS creates a shared data table and then exposes a unique instance of the BO for each row using the shared data table.  Now, this poses a problem for me that I'm unsure of how to solve.  Consider the following scenario:

Public Class BO1
  Private SubBO1 as New BOType
 
  Public ReadOnly Property SomeProperty
    Get
      Return SubBO1.Property
    End Get
  End Property

  Public Sub FillAll()
    Me.FillDataTable("SELECT * FROM MyTable")
    SubBO1.FillAll
  End Sub

  Private Sub BO1_Navigated(.....) Handles Me.Navigated
    SubBO1.SeekToPrimaryKey(Me.SubBO1Key)
  End Sub

End Class

So basically what I've done is created an instance of a SubBO that I want to use inside of the BO1 i'm creating.  As the BO1 row changes, I want to seek to a different row on SubBO1 so that I can easily access properties from that BO with the best performance and lowest amount of memory usage.  This works fine until I use this BO with a BBS.  Once a BBS is used to make this a data source, it causes errors.  Basically what appears to happen is that a lot of instances of the BO get created, but the DataTable isnt in sync somehow.  When it goes to Seek on the navigated event, there is nothing in the data table for the SubBO1.  It looks like the BO instances are created for each row and share the CurrentDataTable, but dont have the SubBO1 DataTable shared among them.  I can solve this by making the SubBO1 Shared, but I dont really want it to be shared because this approach has been causing me some memory issues.  Is it suggested practice when using a BBS to make any BO instances inside of your source BO Shared?  I guess I'm asking what the best approach is in this situation.  And, if I do need to make it shared to prevent this problem, what is the proper way to dispose of a shared BO isntance?

Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
However, the child BOs DataTable is not shared and therefore is empty for all instances created after the original instance of the parent BO. 

It doesn't have to be.  You can programmatically change the child to use a shared data table as well.  Then it would work as you are trying to make it work.  We generally take a different approacha nd use the BusinessLayer.FillMultipleDataTAbles method in cases like this to populate the parent BO and all of the children at the same time (can drastically improve loading performance).  Then we will filter out the child records when referenced through the parent BO.  It is a different approach than you are trying to use, but it will be faster and you won't have to take the route you are currently taking.

I forget, are you a VB or C# shop?

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