Starts in:
0 DAY
18 HRS
17 MIN
33 SEC
Starts in:
0 D
18 H
17 M
33 S
Open Closed

Module ObjectExtension #6958


User avatar
0
infence created

Hi, How to do object Extension for a newly added module. For ex. I added Module A to the main app. I have an entity Apple in ModuleA. I need to add some field to Object Extension . how can i achieve it Provide us with the following info:

  • ABP Framework version:Abp commercial v8.0.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

12 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can check the document: https://docs.abp.io/en/abp/latest/Module-Entity-Extensions

    ObjectExtensionManager.Instance.Modules()
        .ConfigureModuleA(moduleA =>
        {
            moduleA.ConfigureApple(user =>
            {
                user.AddOrUpdateProperty<Guid>(
                    "DepartmentId",
                    property =>
                    {
                        property.UI.Lookup.Url = "/api/departments";
                        property.UI.Lookup.DisplayPropertyName = "name";
                    }
                );
            });
        });
    

    You need to create some extension methods for Module A, for example:

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConfigurationDictionaryExtensions.cs#L8

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/ObjectExtending/IdentityModuleExtensionConfiguration.cs#L8

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs#L301

  • User Avatar
    0
    infence created

    Hi, Thanks for the reply. I have done the same and still its not working.

    Kindly help

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Here are some configurations: https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs#L26 https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs#L77 https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs#L19 https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs#L28 https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs#L107

  • User Avatar
    0
    infence created

    Hi, ModuleExtensionConfigurationHelper .ApplyEntityConfigurationToUi( IdentityModuleExtensionConsts.ModuleName, IdentityModuleExtensionConsts.EntityNames.User, createFormTypes: new[] { typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel.UserInfoViewModel) }, editFormTypes: new[] { typeof(Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel.UserInfoViewModel) } ); in CreateFormTypes what will come for BlazorServer UI

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is the Blazor server config:

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs#L58

    It will automatically add extension fields to create and edit UI

  • User Avatar
    0
    infence created

    ObjectExtensionManager.Instance.Modules() .ConfigureModuleA(moduleA => { moduleA.ConfigureApple(user => { user.AddOrUpdateProperty<Guid>( "DepartmentId", property => { property.UI.Lookup.Url = "/api/departments"; property.UI.Lookup.DisplayPropertyName = "name"; } ); }); }); property.UI.Lookup.Url = "/api/departments"; property.UI.Lookup.DisplayPropertyName = "name"; why is this needed? is this controller Route

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is just an example code; you can check the document https://docs.abp.io/en/abp/latest/Module-Entity-Extensions

  • User Avatar
    0
    infence created

    Hi, Got it.. Thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    : )

  • User Avatar
    0
    infence created

    Hi, alil more help with this. how to add the extensionproperty in DataGrid

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    This is how ABP did :

    https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs#L230-L231 https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor#L121-L156

    The suite generated code for Blazor UI doesn't support module object extension yet, we will improve it in 8.3 version.

  • User Avatar
    0
    infence created

    Thank you

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06