The requested page is not available for the requested platform. You are viewing the content for Default platform.

XafApplication.CreateCustomObjectSpaceProvider Event

Occurs when setting up the application.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

public event EventHandler<CreateCustomObjectSpaceProviderEventArgs> CreateCustomObjectSpaceProvider
Public Event CreateCustomObjectSpaceProvider As EventHandler(Of CreateCustomObjectSpaceProviderEventArgs)

Event Data

The CreateCustomObjectSpaceProvider event handler receives an argument of the CreateCustomObjectSpaceProviderEventArgs type. The following properties provide information specific to this event.

Property Description
Connection Specifies the connection type to be used by an Object Space Provider.
ConnectionString Specifies the connection string to be used by the Object Space Provider's data layer.
IsObjectSpaceProviderOwner Specifies whether or not the Object Space Provider is disposed of when the application is disposed of.
ObjectSpaceProvider Specifies a custom Object Space Provider to be used by the application.
ObjectSpaceProviders Specifies a custom list of Object Space Providers to be used by the application.

Remarks

Handle this event if you require the application to use a custom Object Space Provider. Use the handler's CreateCustomObjectSpaceProviderEventArgs.Connection and CreateCustomObjectSpaceProviderEventArgs.ConnectionString parameters to get the connection type and connection string that are set for the application. The created Object Space Provider should be set for the handler's CreateCustomObjectSpaceProviderEventArgs.ObjectSpaceProvider parameter, so that the default Object Space Provider is not created.

You can also pass several Object Space Providers to the CreateCustomObjectSpaceProviderEventArgs.ObjectSpaceProviders parameter. In this instance, the Object Space Provider appropriate for each particular business object type is determined automatically (see How to: Use Both Entity Framework and XPO in a Single Application). However, if you want to create an Object Space manually, use an overload of the XafApplication.CreateObjectSpace method that takes the objectType parameter.

The Object Space Providers list is assigned to the XafApplication.ObjectSpaceProviders property. Created Object Space Providers are not disposed automatically, and each provider keeps an SQL connection active. You should manually dispose of them when they are not required.

Note

When multiple Object Space Providers are registered in the XafApplication.ObjectSpaceProviders property, the ModuleUpdater.UpdateDatabaseAfterUpdateSchema method is executed multiple times, once for each registered Provider. In this method, before accessing an object of a particular type, check if the current Object Space supports this type using the IObjectSpace.CanInstantiate method.

See Also