xpo-devexpress-dot-xpo-dot-xpodefault-dot-getdatalayer-x28-devexpress-dot-xpo-dot-db-dot-autocreateoption-x29.md
Creates a data layer for the default connection string and default metadata information.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
public static IDataLayer GetDataLayer(
AutoCreateOption defaultAutoCreateOption
)
Public Shared Function GetDataLayer(
defaultAutoCreateOption As AutoCreateOption
) As IDataLayer
| Name | Type | Description |
|---|---|---|
| defaultAutoCreateOption | AutoCreateOption |
An AutoCreateOption value that specifies which operations should be performed when a data store is accessed for the first time.
|
| Type | Description |
|---|---|
| IDataLayer |
The created SimpleDataLayer object.
|
This method creates a corresponding IDataStore object based on the default connection string (returned by the XpoDefault.ActiveConnectionString property) and defaultAutoCreateOption parameter and then creates a SimpleDataLayer object that wraps the created IDataStore object. The metadata information used to create the data layer is obtained via the XpoDefault.GetDictionary method.
The value returned by this method can be used to initialize the XpoDefault.DataLayer property or passed to a Session object’s constructor.
When you have finished working with a data layer you need to dispose of it to release the resources allocated by the data layer.
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetDataLayer(AutoCreateOption) method.
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.
XPO_how-to-display-a-complex-propertys-subproperties-in-data-bound-controls-e742/CS/Form1.cs#L215
{
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema);
Application.Run(new Form1());
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");
XPO_how-to-use-string-functions-in-criteria-e264/CS/UpperFunctionTest.cs#L11
public void Run() {
IDataLayer dl = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema);
UnitOfWork uof = new UnitOfWork(dl);
public Form1() {
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema);
CreateDefaultData();
// init XPO data layer
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema);
XPO_how-to-display-a-complex-propertys-subproperties-in-data-bound-controls-e742/VB/Form1.vb#L205
Shared Sub Main()
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema)
Application.Run(New Form1())
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")
XPO_how-to-use-string-functions-in-criteria-e264/VB/UpperFunctionTest.vb#L12
Public Sub Run()
Dim dl As IDataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema)
Dim uof As New UnitOfWork(dl)
Public Sub New()
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema)
CreateDefaultData()
' init XPO data layer
XpoDefault.DataLayer = XpoDefault.GetDataLayer(AutoCreateOption.DatabaseAndSchema)
See Also