Skip to main content
.NET 6.0+

XpoDefault.GetDataLayer(String, AutoCreateOption) Method

Creates a data access layer.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public static IDataLayer GetDataLayer(
    string connectionString,
    AutoCreateOption defaultAutoCreateOption
)

Parameters

Name Type Description
connectionString String

A connection string.

defaultAutoCreateOption AutoCreateOption

Specifies whether XPO can create a database or update its schema.

Returns

Type Description
IDataLayer

An IDataLayer object.

Remarks

If the value passed to the connectionString parameter is a reference to Data Store Service (URL), the method connects SimpleDataLayer to a Data Store Service client.

The GetDataLayer method throws CannotFindAppropriateConnectionProviderException in the following situations:

A connection string does not contain the XpoProvider attribute and XPO cannot infer the provider name from other attributes.

To get a fully qualified connection string, use the GetConnectionString method of a corresponding connection provider.

A connection string references a Data Store Service and a target platform is .NET Core.

To connect a .NET Core project to a Data Store Service, create and configure DataStoreClientAsync or CachedDataStoreClient. For additional information, see WCF Client in .NET Core.

Tip

Dispose of a data layer instance when it is no longer in use to release the resources it holds.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetDataLayer(String, 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.

See Also