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

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.1.dll

Declaration

[Browsable(false)]
public IDataLayer DataLayer { get; }
<Browsable(False)>
Public ReadOnly Property DataLayer As IDataLayer
[Browsable(false)]
public IDataLayer DataLayer { get; }
<Browsable(False)>
Public ReadOnly Property DataLayer As IDataLayer

Property Value

Type Description
IDataLayer

An object which implements the IDataLayer interface.

Property Value

Type Description
IDataLayer

An object which implements the IDataLayer interface.

Examples

The following code shows how to create a data layer that will be used by all Session objects by default.

By default the XpoDefault.DataLayer property's value is null. So a new data layer is created for each session when it is connected to a data store. In the 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 provided that their 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);
See Also