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?