The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

Session

  • 2 min to read

In terms of XPO, the Session object represents a cache of the persistent objects that have been instantiated during data manipulations with a data store. A session uses a Data Access Layer (DAL for short) to retrieve the persistent objects from a data store and store them. A session automatically creates a DAL provided that the connection properties (such as the database name, user name and password) have been specified.

By default, XPO uses the MS Access OLEDB provider, assumes that the database has the same name as the application, and it resides in the application folder. If the database does not exist, XPO creates it. These default settings can be accessed and customized via the static properties of the XpoDefault class. You can also create and work with your own Session object(s).

You can also use Unit of Work instead of sessions. When working with sessions you need to save each persistent object individually. While working with Units of Work all the changes made to persistent objects are automatically saved to a data store by making a single method call. This is because it tracks every change to every persistent object.

The connection is alive while a session is active, i.e. until the Session.Disconnect method is explicitly called. Disconnect is implicitly called when a Session object is disposed of.

Concepts

Task-Based Help

Online Knowledge Base