Skip to main content
.NET Framework 4.5.2+

Session.Connect() Method

Connects the session to a data store.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.1.dll

NuGet Package: DevExpress.Xpo

Declaration

public void Connect()

Remarks

Call this method to connect the current session to a data store. If the Session.Connection property is specified, the Connect method opens the specified connection. Otherwise, it creates and opens the connection using the connection string specified via the session’s Session.ConnectionString property. If neither of these properties is specified, an object access layer (a SimpleObjectLayer instance) is created for the session based on the XpoDefault.DataLayer property setting. The created object access layer is then used to connect the session to a data store. If the XpoDefault.DataLayer property is not specified either, the default data store provider (AccessConnectionProvider) and connection string are used for connection. As a result, a data access layer and object access layer are created based on this provider.

The Connect method automatically initializes the session’s Session.DataLayer and Session.ObjectLayer properties with relevant SimpleDataLayer and SimpleObjectLayer instances created and used for connection. In addition, the session’s Session.Dictionary property is assigned the object layer’s SimpleObjectLayer.Dictionary property value.

If a data store does not exist, it can automatically be created by the session. To accomplish this, set the session’s Session.AutoCreateOption property to the AutoCreateOption.DatabaseAndSchema value.

Note

If the session is already connected to a data store, the Connect method does nothing.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Connect() 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