The business object in its current state is designed primarily for operation with SQL Server. However, there is intrinsic support for several other providers:
The currently supported backends are:
- Sql Server (SqlClient) - Default
- Visual FoxPro OleDb (OleDbClient)
- MySql (MySqlClient with ByteFx drivers)
- Generic OleDb (OleDbClient)
- Generic Odbc (OdbcClient)
Each of these providers is implemented through wwData provider class which can be dynamically loaded by the wwBusiness class. The concept works like this:
- The Business object holds the type of backend to connect to and a connection string
- When the data is first accessed the backend type determines the type of Data Access class that is instantiated
- The connection string is then passed to the Data Access layer which performs all data access
- Any data operations in the Business object base and subclasses defers to the Data Access Layer (this.Data)
Typically the connection string and backend type is provided in the constructor of the object and this is a one tim implementation step. For example:
public busCustomer()
{
this.Tablename = "wws_customers";
this.ConnectType = ServerTypes.MySql;
this.ConnectionString = "Server=RASNOTEBOOK;DATABASE=WebStore;User ID=WebStore;PASSWORD=wwind;";
}
Typically you will not hard code connection strings but instead create a constructor just like this retrieving the backend type and connection information from the App.Configuration object:
public busCustomer()
{
this.Tablename = "wws_customers";
this.ConnectType = App.Configuration.ConnectType;
this.ConnectionString = App.Configuration.ConnectionString;
ID=WebStore;PASSWORD=wwind;";
}
The result of this is that in ASP.Net applications at least you can switch providers on the fly. Change the App.Configuration setting and the business object will automatically pick up a new provider on the next instantiation. This approach is very flexible as it completely decouples your business logic from the data backend.
© West Wind Technologies, 1996-2018 • Updated: 01/18/04
Comment or report problem with topic