Typical modifications to BusinessEntity source code

Constructors are Marked Private


Milos Business Entities follow industry Best Practices by marking constructors as Private and exposing public static NewEntity and LoadEntity() methods.

Create a NewEntity() Method


/// <summary> /// NewEntity /// Used to create a new entity instance. /// </summary> public static UserBusinessEntity NewEntity() { return new UserBusinessEntity(); }

Create a LoadEntity() Method


/// <summary> /// Load Entity /// Used to create a new entity instance using the passed id. /// </summary> /// <param name="id">Primary Key</param> public static UserBusinessEntity LoadEntity(System.Guid id) { return new UserBusinessEntity(id); }

Override the GetBusinessObject() Method


/// <summary> /// Override the GetBusinessObject method /// </summary> public override EPS.Business.BusinessObjects.IBusinessObject GetBusinessObject() { return UserBusinessObject.NewInstance(); }

Public Property Get() and Set() for Exposed Columns


By default, each column in the underlying tables that needs to be publicly exposed (usually every one except primary and foreign key columns) use code similar to this:
/// <summary> /// Property for Note /// </summary> public string Note { get { return this.GetFieldValue("Note").ToString().Trim(); } set { this.SetFieldValue("Note", value); } }

Enums


Good programmers frequently make use of enums to create a type safe, finite set of choices. These choices are generally saved to a database in a one byte integer column (tinyint in SQL Server). The get() and set() methods of the properties corresponding to enums are typically modified to accept and return enum values instead of the underlying data type.




Last Updated: 8/1/2006