XpoDefault.GetConnectionProvider(IDbConnection, AutoCreateOption) Method
Creates an instance of a connection provider using the specified settings.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v18.2.dll
Declaration
public static IDataStore GetConnectionProvider(
IDbConnection connection,
AutoCreateOption autoCreateOption
)
Parameters
Name | Type | Description |
---|---|---|
connection | IDbConnection | An IDbConnection object that represents an open connection to a data source. |
autoCreateOption | AutoCreateOption | A AutoCreateOption enumeration value that specifies the action which is performed when a session is connected to a data store. |
Returns
Type | Description |
---|---|
IDataStore | The created connection provider. |
Remarks
If the value passed to the connectionString parameter equals null (Nothing in VB), the XpoDefault.ActiveConnectionString is used to instantiate the connection provider.
Example
The following code snippet shows how to create an instance of the SimpleDataLayer without first creating the data layer cache. The data layer is instantiated using the XpoDefault.ActiveConnectionString.
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
//...
SimpleDataLayer dataLayer = new SimpleDataLayer(
XpoDefault.GetConnectionProvider(AutoCreateOption.DatabaseAndSchema));
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetConnectionProvider(IDbConnection, 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.