Back to Devexpress

ObjectSpaceProviderEvents.OnObjectSpaceCreated Property

expressappframework-devexpress-dot-expressapp-dot-objectspaceproviderevents.md

latest3.2 KB
Original Source

ObjectSpaceProviderEvents.OnObjectSpaceCreated Property

Occurs after an Object Space has been created by an IObjectSpaceFactory.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public Action<ObjectSpaceCreatedContext> OnObjectSpaceCreated { get; set; }
vb
Public Property OnObjectSpaceCreated As Action(Of ObjectSpaceCreatedContext)

Property Value

TypeDescription
Action<DevExpress.ExpressApp.ObjectSpaceCreatedContext>

A delegate method that takes a context object as an argument.

|

Remarks

You can handle this event in the following ways:

Use the Application Builder

In the application’s Startup.cs file, add the following lines to the application builder code:

File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs

csharp
using DevExpress.ExpressApp;
// ...
builder.ObjectSpaceProviders.Events.OnObjectSpaceCreated += context => {
    // Use the `context.ObjectSpace` property to access the created Object Space.
    IObjectSpace os = context.ObjectSpace;
    // ...
};
// ...

Use the Options Pattern

In the application’s Startup.cs file, call the services.PostConfigure method to configure the ObjectSpaceProviderOptions as shown below:

File: MySolution.Blazor.Server/Startup.cs, MySolution.Win/Startup.cs, MySolution.WebApi/Startup.cs

csharp
using DevExpress.ExpressApp;
// ...
services.PostConfigure<ObjectSpaceProviderOptions>(options => {
    options.Events.OnObjectSpaceCreated += context => {
        // Use the `context.ObjectSpace` property to access the created Object Space.
        IObjectSpace os = context.ObjectSpace;
        //...
    };
});

See Also

XafApplication.ObjectSpaceCreated

Non-Persistent Objects

How to: Perform CRUD Operations with Non-Persistent Objects

ObjectSpaceProviderEvents Class

ObjectSpaceProviderEvents Members

DevExpress.ExpressApp Namespace