Multiple BO instances with a BBS


Author
Message
Andria Jensen
Andria Jensen
StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 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?

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Well, I would suggest a slightly different approach.  We too have child BOs in which we want to line up with the parent.  If you look at the StrataFlix sample you will see exactly how to achieve this.  But in short, you will create a Custom BBS that wraps the child bo, then inside of the parent BO (not the BBS) you will create the instance of the child BBS and expose it through a property.  The Custom BBS template will do this for you if you use it.  Then in the Get of the exposed ChildBO you will apply a filter.

But let's back up here for a minute anyway.  The example you gave showed concerned of the CurrentRowIndex not reflecting the proper instance.  Well, that isn't true.  The CurrentRowIndex is also shared between the collection.  So technically you should not have an issue there as well.  Finally, if you want to expose this, there are a number of other options.  If you have BaseBO that all of your BOs inherit from, you can set a flag and/or a property that gives you the instance of the BBS and then you have ultimate control.

You started using BBS instances prior to the CustomBBS class being released.  But I would highly recommend looking at the StrataFlix sample and the reporting BBS and BOs that is shows.  Since you have a pathced assebmly, I can send you the recompiled version of the StrataFlix sample.  Let me know when you are ready.

Andria Jensen
Andria Jensen
StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)
Group: Forum Members
Posts: 336, Visits: 497
The problem doesn't seem to be that the CurrentRowIndex isnt working properly.  The problem is really that the DataTable is only being filled for the first instance of the parent BO and is then shared for all other instances.  However, the child BOs DataTable is not shared and therefore is empty for all instances created after the original instance of the parent BO. 

The fill method is where I am filling the parent and child BOs, but since the child BO doesn't have a shared data table like the parent it is not getting filled.  The solution has been to create these child BO instances as shared BOs, but my question is how to dispose of them properly if I use this method. 

Andria Jensen
Andria Jensen
StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I'm sorry, I completely ignored the part of the response where you offered to give me the new StrataFlix project.  That would be great.  Can you email it to me?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K 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?

Andria Jensen
Andria Jensen
StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)
Group: Forum Members
Posts: 336, Visits: 497
We are a vb.net shop.  Does the StrataFlix sample you were talking about use the method you are referring to?
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Yes, in the reports.
Andria Jensen
Andria Jensen
StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)StrataFrame User (422 reputation)
Group: Forum Members
Posts: 336, Visits: 497
ok, so then can i get the version of StrataFlix that goes with the version of the dlls I have?  Please  BigGrin
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