expressappframework-devexpress-dot-expressapp-dot-compositeobjectspace.md
Gets the list of Object Spaces used to handle objects that do not belong to the current Object Space. We recommend that you call the PopulateAdditionalObjectSpaces(XafApplication) method to populate this collection automatically.
Namespace : DevExpress.ExpressApp
Assembly : DevExpress.ExpressApp.v25.2.dll
NuGet Package : DevExpress.ExpressApp
public IList<IObjectSpace> AdditionalObjectSpaces { get; }
Public ReadOnly Property AdditionalObjectSpaces As IList(Of IObjectSpace)
| Type | Description |
|---|---|
| IList<IObjectSpace> |
An IList<T> collection of Object Spaces used to handle objects that do not belong to the current Object Space.
|
| Type | Description |
|---|---|
| InvalidOperationException |
Cannot add the Object Space to the CompositeObjectSpace.AdditionalObjectSpaces collection because another Object Space for the same object types already exists.
|
Use one of the following techniques to fill this collection.
Startup.cs file.AdditionalObjectSpaces collection with all necessary Object Spaces.File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs
using DevExpress.ExpressApp;
//...
builder.ObjectSpaceProviders.Events.OnObjectSpaceCreated = context => {
CompositeObjectSpace compositeObjectSpace = context.ObjectSpace as CompositeObjectSpace;
if (compositeObjectSpace != null) {
if (!(compositeObjectSpace.Owner is CompositeObjectSpace)) {
var objectSpaceProviderService = context.ServiceProvider.GetRequiredService<IObjectSpaceProviderService>();
var objectSpaceCustomizerService = context.ServiceProvider.GetRequiredService<IObjectSpaceCustomizerService>();
compositeObjectSpace.PopulateAdditionalObjectSpaces(objectSpaceProviderService, objectSpaceCustomizerService);
}
}
}
If you need to create an additional Object Space manually, follow the steps below:
AdditionalObjectSpaces collection does not already include a compatible Object Space.File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs
using DevExpress.ExpressApp;
// ...
builder.ObjectSpaceProviders.Events.OnObjectSpaceCreated = context => {
var nonPersistentObjectSpace = context.ObjectSpace as NonPersistentObjectSpace;
if (nonPersistentObjectSpace != null) {
if (!nonPersistentObjectSpace.IsKnownType(typeof(Person), true)) {
IObjectSpace additionalObjectSpace = context.ServiceProvider.GetRequiredService<IObjectSpaceFactory>()
.CreateObjectSpace<Person>();
// Customize the additionally created Object Space.
nonPersistentObjectSpace.AdditionalObjectSpaces.Add(additionalObjectSpace);
nonPersistentObjectSpace.Disposed += (s2, e2) => {
additionalObjectSpace.Dispose();
};
}
}
};
// ...
See Also