Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

Session.DataLayer Property

Gets the data access layer used by the current session to access a data store.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

[Browsable(false)]
public IDataLayer DataLayer { get; }

Property Value

Type Description
IDataLayer

An object which implements the IDataLayer interface.

Example

This example demonstrates how to create a data layer that will be used by all Session objects.

The XpoDefault.DataLayer property’s value is null by default. XPO creates a new data layer for each session when the session is connected to a data store.

In this example, a data layer (represented by the SimpleDataLayer class object) is created and assigned to the XpoDefault.DataLayer property using the XpoDefault.GetDataLayer method.

In this case, newly created sessions will use this data layer. The sessions’ Session.Connection and Session.ConnectionString properties are not initialized.

using DevExpress.Data.DB;
using DevExpress.Xpo;

string forcedConnectionString = ...;
XpoDefault.DataLayer = XpoDefault.GetDataLayer(forcedConnectionString, 
    AutoCreateOption.DatabaseAndSchema);

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataLayer property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also