Skip to main content
All docs
V26.1
  • SecuredEFCoreObjectSpaceProvider<TDbContext> Class

    Provides an Object Space in EF Core-based applications that use the Security System.

    Namespace: DevExpress.EntityFrameworkCore.Security

    Assembly: DevExpress.EntityFrameworkCore.Security.v26.1.dll

    NuGet Package: DevExpress.ExpressApp.EFCore

    Declaration

    public class SecuredEFCoreObjectSpaceProvider<TDbContext> :
        EFCoreObjectSpaceProvider<TDbContext>,
        INonsecuredObjectSpaceProvider
        where TDbContext : DbContext

    Type Parameters

    Name Description
    TDbContext

    The database provider

    Remarks

    XAF uses an Object Space Provider to create Object Spaces. The following Object Space Provider types are included in XAF:

    Object Space Provider Object Space Application Builder Method
    EFCoreObjectSpaceProvider<TDbContext> EFCoreObjectSpace AddEFCore
    XPObjectSpaceProvider XPObjectSpace AddXpo
    SecuredEFCoreObjectSpaceProvider<TDbContext> SecuredEFCoreObjectSpace AddSecuredEFCore
    SecuredObjectSpaceProvider SecuredXPObjectSpace AddSecuredXpo
    NonPersistentObjectSpaceProvider NonPersistentObjectSpace AddNonPersistent

    XAF applications configure Object Space Providers through the Application Builder’s ObjectSpaceProviders properties: IBlazorApplicationBuilder.ObjectSpaceProviders and IWinApplicationBuilder.ObjectSpaceProviders. When you create an application with the Template Kit, it registers Object Space Providers for the selected preset.

    Refer to the following topic for instructions on how to add custom Object Space Providers to your application: Custom Object Space Provider.

    Note

    When multiple Object Space Providers are registered in the application, 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.

    The following example demonstrates how to create the SecuredEFCoreObjectSpaceProvider in a non-XAF application.

    using DevExpress.EntityFrameworkCore.Security;
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Security;
    using DevExpress.Persistent.Base;
    using DevExpress.Persistent.BaseImpl.EF.PermissionPolicy;
    using Microsoft.EntityFrameworkCore;
    using System.Configuration;
    // ...
    class Program {
        static void Main() {
            AuthenticationStandard authentication = new AuthenticationStandard();
            SecurityStrategyComplex security = new SecurityStrategyComplex(
                typeof(PermissionPolicyUser), typeof(PermissionPolicyRole),
                authentication
            );
            var objectSpaceProvider = new SecuredEFCoreObjectSpaceProvider<ApplicationDbContext>(security,
                XafTypesInfo.Instance, ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString,
                (builder, connectionString) => builder.UseConnectionString(connectionString)
            );
            // ...
        }
    }
    

    You can find the full example in the following GitHub repository: How to use the Integrated mode of the Security System in non-XAF applications (EF Core).

    Inheritance

    Object
    EFCoreObjectSpaceProvider<TDbContext>
    SecuredEFCoreObjectSpaceProvider<TDbContext>
    See Also