﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Filling a BO from a BBS</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 00:17:11 GMT</lastBuildDate><ttl>20</ttl><item><title>Filling a BO from a BBS</title><link>http://forum.strataframe.net/FindPost16155.aspx</link><description>I have created several custom BBS's for use in my DX report.&amp;nbsp; So far, all is going quite well.&amp;nbsp; One thing that would make my life a lot easier is being able to access my custom fill methods from the&amp;nbsp;BO.&amp;nbsp; Here is an example of my code to fill a BO which fills the BBS which provides data for my report:&lt;BR&gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;public&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;partial&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PackingListDS&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BusinessBindingSource&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; PackingListDS()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;BusinessObject = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PackingListBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; PackingListDS(&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;IContainer&lt;/FONT&gt;&lt;FONT size=2&gt; container)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;BusinessObject = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;PackingListBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Fill(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; pPLIndex)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT size=2&gt;BusinessObject.FillByPrimaryKey(pPLIndex);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;This works great!&amp;nbsp; But, what if I want to fill the BO with a different method than the base methods (MyBO.FillWithMyReallyCoolMethod())?&amp;nbsp; If I could somehow cast the BBSs BO as the BO of choice, then I could get to them.&amp;nbsp; How do I do this?&lt;BR&gt;&lt;BR&gt;Thanks,&lt;BR&gt;Bill</description><pubDate>Mon, 05 May 2008 18:32:56 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Filling a BO from a BBS</title><link>http://forum.strataframe.net/FindPost16164.aspx</link><description>LOL...thanks...hope it helps :)</description><pubDate>Mon, 05 May 2008 18:32:56 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Filling a BO from a BBS</title><link>http://forum.strataframe.net/FindPost16162.aspx</link><description>Totally Awesome! :w00t: :w00t: :w00t:&lt;/P&gt;&lt;P&gt;(bows)</description><pubDate>Mon, 05 May 2008 18:19:50 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Filling a BO from a BBS</title><link>http://forum.strataframe.net/FindPost16157.aspx</link><description>Really, the best way would be to create your ReportBaseBBS class as a generic class that must be inherited and accepts the BOs that it will represent as generic inheritance definitions.&amp;nbsp; This would allow you to talk straight to the business objects in strong-typed code without having to CType the object.&amp;nbsp; Here is what the report BBS base class would look like:&lt;P&gt;&lt;STRONG&gt;Step 1 - Base Report BBS Class&lt;BR&gt;&lt;/STRONG&gt;This clas is the abstract class that all other report BBS classes would inherit from.&amp;nbsp; You'll see that the definition requires a primary business object to be specified (you can add all of the required BOs that you want to, but this is not necessary as other BBS classes could be exposed on the actual classes [i.e. MyCustomersBBS, MyOrdersBBS, etc.]).&amp;nbsp; But we know that we are going to need at least one business object for each BBS.&amp;nbsp; So you can see that the class defined a generic parm called TPrimaryBO (you can call this whatever you want).&amp;nbsp; This will require a BusinessLayer class with a constructor (that is what the new() is doing).&lt;/P&gt;&lt;P&gt;[codesnippet]/// &amp;lt;summary&amp;gt;&lt;BR&gt;/// Create the base class of the reporting engine&lt;BR&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;public abstract class ReportBaseBBS&amp;lt;TPrimaryBO&amp;gt; : MicroFour.StrataFrame.Business.BusinessBindingSource where TPrimaryBO : BusinessLayer, new()&lt;BR&gt;{&lt;/P&gt;&lt;P&gt;#region&amp;nbsp; Constructors&lt;/P&gt;&lt;P&gt;/// &amp;lt;summary&amp;gt;&lt;BR&gt;/// Default Constructor&lt;BR&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;public ReportBaseBBS()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //-- Create a new instance of the primary business object that this class wraps&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.BusinessObject = _PrimaryBO;&lt;BR&gt;}&lt;/P&gt;&lt;P&gt;#endregion&lt;/P&gt;&lt;P&gt;#region&amp;nbsp; Declare Privates&lt;/P&gt;&lt;P&gt;private TPrimaryBO _PrimaryBO = new TPrimaryBO();&lt;/P&gt;&lt;P&gt;#endregion&lt;/P&gt;&lt;P&gt;#region&amp;nbsp; Public Properties&lt;/P&gt;&lt;P&gt;/// &amp;lt;summary&amp;gt;&lt;BR&gt;/// Exposes the primary business object so that you can reference it in code&lt;BR&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;/// &amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;BR&gt;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;BR&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;public TPrimaryBO PrimaryBO&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return _PrimaryBO;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;&lt;P&gt;#endregion&lt;/P&gt;&lt;P&gt;}[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2 - Creating a Customers BBS Class&lt;BR&gt;&lt;/STRONG&gt;The next step would be creating the custom class that inherits the ReportBaseBBS and specifies which business object to wrap.&amp;nbsp; In the below example, you can see that we are inheriting the ReportBaseBBS class and supplying the business object type that will be the primary BO in this class (TPrimaryBO).&lt;/P&gt;&lt;P&gt;[codesnippet]/// &amp;lt;summary&amp;gt;&lt;BR&gt;/// This class is a BBS wrapper for the customers business object type&lt;BR&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;public class CustomersReportBBS : ReportBaseBBS&amp;lt;CustomersBO&amp;gt;&lt;BR&gt;{&lt;/P&gt;&lt;P&gt;}[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 3 - Now you can directly access anything on the Primary BO&lt;BR&gt;&lt;/STRONG&gt;You will see in the below code sample, that once the CustomersReportBBS class is created, you can directly access the wrapped BO now through the property that was created in the ReportBaseBBS class (PrimaryBO).&lt;/P&gt;&lt;P&gt;[codesnippet]public class TestCode&lt;BR&gt;{&lt;/P&gt;&lt;P&gt;/// &amp;lt;summary&amp;gt;&lt;BR&gt;/// Just shows how to use the code&lt;BR&gt;/// &amp;lt;/summary&amp;gt;&lt;BR&gt;/// &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;public TestCode()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustomersReportBBS cust = new CustomersReportBBS();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //-- You can now access every method, etc. strong-typed through code since it is exposed&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp; through the PrimaryBO property using the typed generic.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cust.PrimaryBO.FillWithMyCoolMethod();&lt;BR&gt;}&lt;/P&gt;&lt;P&gt;}[/codesnippet]&lt;/P&gt;&lt;P&gt;This would be the cleanest way to achieve what you are trying to do.&amp;nbsp; For those VB.NET developers, here is the VB code:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;VB.NET&amp;nbsp;- Step 1&lt;/STRONG&gt;&lt;BR&gt;[codesnippet]''' &amp;lt;summary&amp;gt;&lt;BR&gt;''' Create the base class of the reporting engine&lt;BR&gt;''' &amp;lt;/summary&amp;gt;&lt;BR&gt;''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;Public MustInherit Class ReportBaseBBS(Of TPrimaryBO As {BusinessLayer, New})&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits MicroFour.StrataFrame.Business.BusinessBindingSource&lt;/P&gt;&lt;P&gt;#Region " Constructors "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' Default Constructor&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;/summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub New()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create a new instance of the primary business object that this class wraps&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.BusinessObject = _PrimaryBO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;#End Region&lt;/P&gt;&lt;P&gt;#Region " Declare Privates "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private _PrimaryBO As New TPrimaryBO()&lt;/P&gt;&lt;P&gt;#End Region&lt;/P&gt;&lt;P&gt;#Region " Public Properties "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' Exposes the primary business object so that you can reference it in code&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;/summary&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public ReadOnly Property PrimaryBO() As TPrimaryBO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _PrimaryBO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;/P&gt;&lt;P&gt;#End Region&lt;/P&gt;&lt;P&gt;End Class[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;VB.NET - Step 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[codesnippet]''' &amp;lt;summary&amp;gt;&lt;BR&gt;''' This class is a BBS wrapper for the customers business object type&lt;BR&gt;''' &amp;lt;/summary&amp;gt;&lt;BR&gt;''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;Public Class CustomersReportBBS&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inherits ReportBaseBBS(Of CustomersBO)&lt;/P&gt;&lt;P&gt;End Class[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;VB.NET - Step 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[codesnippet]Public Class TestCode&lt;/P&gt;&lt;P&gt;''' &amp;lt;summary&amp;gt;&lt;BR&gt;''' Just shows how to use the code&lt;BR&gt;''' &amp;lt;/summary&amp;gt;&lt;BR&gt;''' &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;BR&gt;Public Sub New()&lt;BR&gt;Dim cust As New CustomersReportBBS()&lt;/P&gt;&lt;P&gt;'-- You can now access every method, etc. strong-typed through code since it is exposed&lt;BR&gt;'&amp;nbsp;&amp;nbsp; through the PrimaryBO property using the typed generic.&lt;BR&gt;cust.PrimaryBO.FillWithMyCoolMethod()&lt;BR&gt;End Sub&lt;/P&gt;&lt;P&gt;End Class[/codesnippet]</description><pubDate>Mon, 05 May 2008 16:38:29 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>