StrataFrame Forum

How To - Completely non-UI use of BOs.

http://forum.strataframe.net/Topic21761.aspx

By Alan P Bourke - 2/2/2009

Does anyone have a quick example of how to leverage an BO as defined in an external BO Library from within an non-UI application, such as a Console application ? I presume if the BO is configured and working within it's own BO LIbrary project then I should be able to reference the DLL and use it without having to manually implement SetDataSources et al ?



I can see various postings skirting round the issue on the forum but no concrete examples.



Many thx in advance ...
By Trent L. Taylor - 2/2/2009

You can most definitely do this and there really isn't much to explain other than the following:

  • Add a reference to your BO library within your console app
  • It will also require a reference to the MicroFour StrataFrame Base and MicroFour StrataFrame Business assemblies
  • Next, you will need to setup your datasources prior to attempting to execute a query on the BO.  This is generally done in the program.cs or Appmain.vb files in the SetDataSOurces method in a standard SF app.  But all you need to do is setup the datasource manually prior to executing queries on the BO.

    MicroFour.StrataFrame.Data.DataBasics.DataSources.Add(New SqlDataSourceItem("","MyConnectionString"))
By Alan P Bourke - 2/2/2009

Thanks. I guess I have a gap in my understanding thus far - I assumed that the BO would know how to connect to the data already without having to set up a data source.



Ah well, onward ...
By Greg McGuffey - 2/2/2009

The basic architecture allows for BOs to be loosely coupled to the data source. I.e. this allows you to hot swap datasources on the fly as needed (like you might do if you provide online/offline data access or if you have some sort of fall back database server). Also, this allows for many BOs to share the same data source. The datasource encapsulates the connection info, while the BO encapsulates data access and business rules.



Is that making more sense?
By Alan P Bourke - 2/2/2009

Absolutely, thanks Greg.
By Greg McGuffey - 2/3/2009

Glad it helped!
By Richard Keller - 2/3/2009

Create a Root Business Object and have all your BO's Inherit from it with your connection string.  What we do is provide a utility that sets the Connection although it is in a Non-UI Configuration.  The Root BO knows how to connect and cascades down to the LocalHost embedded string if not connected.   We also add a few other functions that are used all the time like a FIllAllRecords Data Retrieval Method.