Business Objects

From CaisisWiki

Revision as of 14:54, 7 May 2008 by Bas (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Business objects in Caisis represent database tables, allowing clients (e.g. Caisis.UI) to transparently store and retrieve data, and access table metadata.

Creating a New Business Object

Before creating a new Business Object, look at the source code for an existing Business Object (preferably one that represents a database table similar to the one for which you are creating a new Business Object) and compare it to the structure of the database table it represents.

When initializing a Business Object the initialization methods of the abstract BizObject class (which all Business Object should extend) will treat all public static String members of the Business Object as column names of the table that the Business Object represents. Furthermore, the Attributes associated with the Business Object and its members represent table and field metadata, respectively.

Consider the following snippet of Caisis.BusinessObject.Encounter.cs:

   public class Encounter : BizObject
       public static readonly String PatientId = "PatientId";
       public static readonly String EncounterId = "EncounterId";
       public static readonly String EncPending = "EncPending";
       public static readonly String EncDateText = "EncDateText";
       public static readonly String EncDate = "EncDate";
       public static readonly String EncType = "EncType";

For instance, the Encounters table has a primary key of EncounterId, a parent table and key of Patients and PatientId, respectively, and a many-to-one relationship with the Patients table (i.e. a given patient may have many encounters, but not vice-versa). EncounterId and PatientId are of datatype Int32, and the EncType field is of datatype String. The DataColumns of the DataTable in the Encouter Business Object will have datatypes corresponding to these DataType Attributes.

Personal tools