XpoDefault.DataLayer Property
Gets or sets the default data access layer which is used by Session objects by default, to access a data store.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v18.2.dll
Declaration
Property Value
Type | Description |
---|---|
IDataLayer | An object which implements the IDataLayer interface; null - in this case, every new session will create and use its own data layer. |
Example
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);
Related GitHub Examples
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.