Steps to Create a New Project with a New Business Object

Follow these steps to create a new project with a new business object (manually).

In this example, I assume you are creating a simple business objects that handles a simple products table stored in SQL Server (such as the Northwind products table).


  1. Create a new class library project (VB or C#)

    1. If you create a VB.NET project, set option strict on in the project properties, to operate in a more realistic environment.
    2. Delete the default class that gets created automatically.

  2. Add a reference to BusinessObject.dll as well as Core.dll and Data.dll to your project.
  3. Add a new class to your business objects called "ItemBusinessObject".

    1. Change this class so it inherits from EPS.Business.BusinessObjects.BusinessObject
    2. Add a private constructor to prevent direct instantiation of an object (we want more control than that!).
    3. Add a static/shared NewInstance() method for the purpose of allowing controlled instantiation of the object.
    4. Note that the editor automatically adds an overridden method named "Configure". (If not, override this method manually... otherwise the app won't compile)
    5. Set the strMasterEntity and strPrimaryKeyField fields in an overridden version of the Configure() methods which is provided by many framework objects.

  4. Compile your new application


Here's the code we have created so far:

VB.NET:

Public Class ItemBusinessObject Inherits EPS.Business.BusinessObjects.BusinessObject Private Sub New() End Sub Public Shared Function NewInstance() As ItemBusinessObject Return New ItemBusinessObject End Function Protected Overrides Sub Configure() Me.MasterEntity = "products" Me.PrimaryKeyField = "item_pk" End Sub End Class

C#:

public class ProductBusinessObject : EPS.Business.BusinessObjects.BusinessObject { private ProductBusinessObject() {} public static ProductBusinessObject NewInstance() { return new ProductBusinessObject (); } protected override void Configure() { this.MasterEntity = "products" ; this.PrimaryKeyField = "product_pk" ; } }

Note: Do not forget that whatever client application uses this business object needs to configure data access as defined in Documentation_ConfigurationOptions

Note: The private constructor and the static method is not strictly required, but it is a good idea. (For simplicity, this detail is ommited in subsequent examples).

Note: In real-life scenarios, business objects use Stored Procedures as their means to access data (at least that is the case when SQL Server - as well as a few other databases - is/are used). For simplicity, we will ignore that fact in this section. However, in a real life implementation, the Configure() method would probably have one more line of code:

protected override void Configure() { this.SetDataAccessMethod(EPS.Data.DataRowProcessMethod.StoredProcedures); this.MasterEntity = "products"; this.PrimaryKeyField = "product_pk"; }


Last Updated: 8/7/2006