Open Closed

Proper way to Extending Tenant so Custom Properties are Returned #6371


User avatar
0
matt@mpathic.ai created
  • ABP Framework version: v7.4.0
  • UI Type: Angular / MVC / Blazor WASM / Blazor Server
  • Database System: EF Core (PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace: N/A
  • Steps to reproduce the issue:

We have an MVC solution to which we've added our own module. In the web project of the website (not the module) we've extended the Tenant object with something like this: ObjectExtensionManager.Instance.Modules().ConfigureSaas(identity => { identity.ConfigureTenant(user => { user.AddOrUpdateProperty<string>("MyProperty", x => { x.UI.OnTable.IsVisible = false; x.UI.OnCreateForm.IsVisible = true; x.UI.OnEditForm.IsVisible = true; x.UI.Order = 4;

                });

... The above works well and it produces the admin UI we would expect, allowing us to enter values for "MyProperty" for each tenant. The question is: What do I need to change in my custom module so that I can load a tenant object with all the extra properties? The CurrentTenant object only has standard ID and Name properties... Things we've tried: passing ITenantRepository or IRepository<Tenant> as DI parameter to our controller. Initially the interface wasn't registered weren't able to register it in a way that doesn't fail Override CurrentTenant with MyCurrentTenant similar to #1, this required registering dependencies even after registering them, they didn't work Things we don't understand: why isn't ITenantRepository already registered? What's the right way to register it? Is using the tenant repostitory the right way to approach the problem? Should we use it to get the tenant by ID, or is there a better way to get extra properties for the current tenant?


1 Answer(s)
  • User Avatar
    0
    matt@mpathic.ai created

    We actually found a solution based on information in this blog post, but it would be helpful if this information was included in the ABP documentation:

    https://blog.antosubash.com/posts/abp-extend-tenant-with-custom-host#add-a-custom-tenant-repo

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11