| Milos How-To |
| Steps to Create a New Project with a New Business Object |
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).
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"; }