The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Session.Connect() Method

Connects the session to a data store.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public void Connect()
Public Sub Connect
public void Connect()
Public Sub 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.

See Also