XafApplication.ObjectSpaceProvider Property
Provides access to the application’s Object Space Provider.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
[Browsable(false)]
public IObjectSpaceProvider ObjectSpaceProvider { get; }
#Property Value
Type | Description |
---|---|
IObject |
An instance of the class that implements the IObject |
#Remarks
XAF uses an Object Space Provider to create Object Spaces. It is a class that implements members of the IObjectSpaceProvider interface. The following Object Space Provider types are supplied with XAF:
- XPObjectSpaceProvider - Creates the XPObjectSpace Object Space that manipulates data using the XPO ORM system.
- EFCoreObjectSpaceProvider<TDbContext> - Creates the EFCoreObjectSpace Object Space that manipulates data using the Entity Framework ORM system.
- SecuredObjectSpaceProvider - Creates the SecuredXPObjectSpace Object Space that takes the current user’s security permissions into account.
- SecuredEFCoreObjectSpaceProvider<TDbContext> - Creates the SecuredEFCoreObjectSpace Object Space that takes the current user’s security permissions into account.
- NonPersistentObjectSpaceProvider - Creates the NonPersistentObjectSpace Object Space that manipulates non-persistent object instances.
By default, XPObjectSpaceProvider is created because the WinForms and ASP.NET Web Forms application project templates override the CreateDefaultObjectSpaceProvider method of the corresponding XafApplication descendant in the following manner:
public partial class MainDemoWinApplication : WinApplication {
//...
protected override void CreateDefaultObjectSpaceProvider(
CreateCustomObjectSpaceProviderEventArgs args) {
args.ObjectSpaceProvider = new XPObjectSpaceProvider(args.ConnectionString, args.Connection);
}
}
The CreateDefaultObjectSpaceProvider method is called when creating an Object Space Provider during the application’s setup if a particular Object Space Provider is not passed as a parameter in the Setup method call. So, check that an Object Space Provider is not passed in your Setup method call, as in the following code:
static class Program {
// ...
public static void Main() {
// ...
MainDemoWinApplication application = new MainDemoWinApplication();
// ...
application.Setup();
application.Start();
// ...
}
}
To create an Object Space Provider, the application uses the connection string specified using the XafApplication.ConnectionString property. If you need to specify a custom connection string or create an Object Space Provider of another type, implement a custom override of the CreateDefaultObjectSpaceProvider method. Alternatively, you can handle the XafApplication.CreateCustomObjectSpaceProvider event to pass a custom Object Space Provider.
Note
XAF uses the first registered Object Space Provider for the following purposes:
- To get
Xaf
and XafApplication. Object Space Provider Application. property values.Connection String - To pass this Provider as the Custom
Check ObjectCompatibility Event Args Space argument.Provider - To update an application.
Ensure that Non
Note that in applications with the Application Builder, you need to use the Application Builder’s ObjectXaf
method or Xaf
event to register Object Space Providers. Refer to the following help topic for more information on how to do this: Integrate Application Builders into Existing Applications.
We strongly recommend this because the use of the Xaf
method and Xaf
event conflicts with IObject
This technique also improves performance of your application because the application instance is not created in this case.