Structure of a business object
Versions
Video Presentations

Each business object has one or more tables and a minimum of 3 classes.
Exemplary diagram of tables to an object

The exemplary diagram shows an exemplary  object Client with its service objects and tables. The corresponding classes have identical names with the tables. One can also see that the name of the Primary Key must be composed of the name of the object and an ID. In this way, provided the name of the object is known, the names of the class, the table and the primary key are also automatically known. From the tables shown above, there is only one with no corresponding class – the ClientCategory - because it is used to save the so called Multiple Property, which only reflects the fact that a single client can have more than one associated categories. This table is relational and is managed by the parent object, in this case Client, through the CategoryIDs property, which is a string of comma delimited CategoryID values.

For each business object there are three classes – object, collection and data source. They inherit  the three basic classes BusinessObject, BusinessObjectCollection and BusinessObjectDataSource.
The BusinessObject class serves to administer a single record in the related table, has a constructor by primary key and a Code (as both are unique). The other main method of the class is Update (bool Fetch, bool FireEvent), which records the changes in the database. The class itself decides if this is a new or an existing record and creates the necessary database query. All properties of the object with their types and other attributes are registered for each business object, so that the object can always know if a given property is mandatory or not, which copy of the database it relates to etc. There is also one new special property – CurrentRecordReference. It is usually an auto-generated expression of the reference of the object, which is provided by the DataSource class.

Collections on the other hand provide the option of working with more than one record in the same object – for example to create lists, visualize forms etc. Each collection has several important methods– the constructor – BusinessObjectCollection(string FilterString, string OrderString, int Page, int Limit, int DataMode), which allows for the creation of a collection with a specific filter, rearranging and paging; GetNext(), which allows to enumerate the collection in а “while” cycle; GetCount(), which returns the current number of records in the collection; and the static GetTotalCount(string FilterString), which returns the number of records in the table that match the filter.

The third class – BusinessObjectDataSource, is a lightweight object, which serves to return, process and expand the queries used by an object to obtain its data from the database. A single full-scope query contains both all the properties of the object and all the references of its properties, which are objects (e.g. the Client class has both a Client::CityID, and a Client::CityIDReference). These references are obtained from the DataSources of the related objects real-time. There are three types of queries – Full, Simple and Search. The first type returns all the properties necessary to build the form of the object. Usually this query is too heavy to be enlisted which is why the second type exists – Simple query. In practice the developer points out those properties, which might be considered useless or too heavy to visualize in a list and are therefore excluded when executing a Simple query. The third option, Search, is designed especially for use in the interface control ObjectPicker, which replaces the standard <select> tag in HTML.
 

EXEMPLARY DIAGRAM OF CLASSES TO THE CLIENT OBJECT

 
БългарскиSite Map
Web Site, SEO by Calipers

Ladger