Occurs when setting up the application.
NuGet Package: DevExpress.ExpressApp
The CreateCustomObjectSpaceProvider event's data class is CreateCustomObjectSpaceProviderEventArgs. The following properties provide information specific to this event:
|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.|
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. 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.
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.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateCustomObjectSpaceProvider event.
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.