Data Access Layer
- 2 minutes to read
A data access layer (DAL for short) is a bridge between an object access layer, which generates general type statements, and a data store provider (an IDataStore implementation), which provides a connection to individual data stores (MS SQL Server, MS Access databases, etc.) A DAL (an IDataLayer implementation) provides a set of methods allowing for unified access to data stores (obtaining data from a data store, updating its data and schema) via object access layers.
Though a DAL is a part of XPO’s internal infrastructure, there are specific instances when you can create data access layers manually and use them explicitly in your applications. The most common is to connect to a data store using a DAL and share it across multiple sessions to improve an application’s performance.
By default, each session object creates a new DAL when a connection to a data store is about to be established. You can, however, force a session to use an existing DAL. In this case, specific initialization steps are omitted and so the connection is established faster.
To make a session use a specific DAL do one of the following.
- Assign the DAL to the XpoDefault.DataLayer property. All newly created sessions whose DALs are not initialized will use this DAL by default.
- Pass the DAL to the Session or UnitOfWork object’s constructor.
- Pass the DAL to the Connect method of a Session or UnitOfWork object (see Session.Connect for details) to establish a connection to a data store.
- Object Access Layer
- Unit of Work
- Database Systems Supported by XPO
- Transferring Data via WCF Services