DAL Architecture

Exploring the automatically generated DAL source code

The internal structure of an ODS DAL

The DAL source code generated by ODS is divided into three distinct sections: the data store providers, the state classes and the data access classes.

The data store provider source code

Database Agnostic Diagram

It is the job of the data store provider source code to communicate with the underlying database. In fact the data store provider code is the only code in the DAL that communicates directly with the database. It is responsible for creating a new database, upgrading existing databases and storing and retrieving objects.

A DAL can contain the source code for many different data store providers. Each data store provider is responsible for communicating with a different type of database. There might be one data store provider that deals with SQL Server 2000 databases and another that deals with MySQL databases.

All data store providers implement the I<DALName>DataStoreProvider interface. The interface is specific to your DAL and is automatically generated by ODS. The interface provides an abstract way to deal with databases.

Since you write your application to deal with I<DALName>DataStoreProvider objects, you can switch between data store providers without changing your code. This allows you to easily switch between database types.

The state source code

The state classes represent the data/state of objects stored in the database. There is a state class to hold data for each class that you define in your ODS solution. Each class has properties but no methods. State objects and collections of these objects are used to pass state around within the DAL and with your application. The Enums in your ODS solution are also implemented in the state area of the DAL.

The data access source code

The data access classes are the visible front end of the DAL. They implement the CRUD methods that you will use to store and retrieve state objects in the database.

The data access classes are actually façade classes. The methods are implemented by the data store providers - they map directly to data store provider methods. It is the data store providers that actually access the database, passing state objects back and forth.