Data Access

Overview

When accessing data in LS One you use two types of classes called BusinessObjectsand DataProviders.

  • BusinessObjects: is a class that represents a single record in a table. Used in the data model of the Site Manager and LS One POS. When you deal with existing data in the system you will be fetching business objects from the database and saving business objects into the database.
  • DataProviders: A class that accesses the database and returns a Business object or a list of business objects. It also handles deleting and saving data from a business object to the appropriate database table.

Each DataProvider and BusinessObject should only cover a single table or a single type of BusinessObject. There are exceptions where it makes sense to join two tables to form a single logical record of data but the general rule is that you do not use a single DataProvider for multiple different BusinessObjects.

For example, the StoreData data provider only returns Store business objects and the HardwareProfileData data provider only works for the HardwareProfile business object

Other data layer components:

  • SharedDatabase: Every data provider uses SharedDatabase to execute the queries for it. SharedDatabase makes sure that the Data Director knows what to replicate and it also provides tool for common SQL operations.
  • The forth component of the datalayer is the DatabaseUtil, which is used to create and edit tables in the database. You create update scripts that that either the Site Manager or the LS One POS run the next time they start up.

These four components are the only ones that deal with getting data to and from the database.

Database version and updating

The Database version tells the DatabaseUtil if it should try and update the database or not. The DatabaseUtil checks the highest number of database scripts it has and compares them to the current database version. If the DatabaseUtil contains a script with a higher number, then the DatabasUtil will run all scripts from the current version to the latest version contained in the DatabaseUtil on the current database.

The current database version is stored in the table POSISINFO and is represented by string XXXXX-YY, so, 00186-00. The former part is the official LS Retail database version and the latter part is the partner version. LS Retail will only update the LS Retail database version number when releasing new versions.

Customization possibilities

By customizing the data layer you can:

  • Access data from code
  • Modify the database
  • Extend existing data
  • Create new data

It is not recommended to alter existing data tables in LS One to avoid merging and conflicts when updating between versions of the software. It is better to extend sinci it does not have impact on existing code.

 

In this lesson you should first learn how to access existing data