xpo-devexpress-dot-xpo-dot-xpodefault.md
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.v25.2.dll
NuGet Package : DevExpress.Xpo
public static IDataLayer DataLayer { get; set; }
Public Shared Property DataLayer As IDataLayer
| 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.
|
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);
Imports DevExpress.Data.DB
Imports DevExpress.Xpo
Dim forcedConnectionString As String = ...
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.
how-to-bind-wpf-grid-to-data/CS/CodeBehind/XPO/InfiniteAsyncSource/Issues/ConnectionHelper.cs#L16
public static void Connect() {
XpoDefault.DataLayer = CreateDataLayer(true);
}
public static void Connect() {
XpoDefault.DataLayer = CreateDataLayer(true);
}
XPO_how-to-make-user-friendly-object-identifiers-e825/CS/Program.cs#L17
static void Main(string[] args) {
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema);
Do("A");
CriteriaOperatorsCheatSheet/CS/CriteriaOperatorCheatSheet/ConnectionHelper.cs#L37
dictionary.GetDataStoreSchema(persistentTypes);
XpoDefault.DataLayer = new ThreadSafeDataLayer(dictionary, provider);
} else {
serializableObjectLayer.CanLoadCollectionObjects.ToString();
XpoDefault.DataLayer = null;
XpoDefault.Session = null;
how-to-bind-wpf-grid-to-data/VB/CodeBehind/XPO/InfiniteAsyncSource/Issues/ConnectionHelper.vb#L12
Public Sub Connect()
XpoDefault.DataLayer = CreateDataLayer(True)
End Sub
XPO_how-to-make-user-friendly-object-identifiers-e825/VB/Program.vb#L18
Shared Sub Main(ByVal args() As String)
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema)
[Do]("A")
serializableObjectLayer.CanLoadCollectionObjects.ToString()
XpoDefault.DataLayer = Nothing
XpoDefault.Session = Nothing
DatabaseHelper.DataLayer = XpoDefault.GetDataLayer(cs, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema)
XpoDefault.DataLayer = DatabaseHelper.DataLayer
DatabaseHelper.SequenceDataLayer = XpoDefault.GetDataLayer(cs, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema)
XPO_how-to-implement-custom-aggregates/VB/XpoCustomAggregate/DataAccess/ConnectionHelper.vb#L13
Public Sub Connect(Optional ByVal threadSafe As Boolean = True)
XpoDefault.DataLayer = CreateDataLayer(threadSafe)
End Sub
See Also