Open Closed

How to inject a repository to supply all the tenantfull and tenantless records of a database table? #115


User avatar
0
talhazengin created

I am working with an abp background worker.

When i injected a repository, scoped or not scoped. The repository only supplies data for tenantless (current tenant is null) records of the entity (entity is a MultiTenant entity). But the system has many tenants. As i see the repository only supplies tenantless records when there is not a current tenant.

I want to inject my entity repository to reach all the records of my entity from all the sources, i mean all the tenant and not tenant related records (tenantfull and tenantless).

How can i do this? Thanks.


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

    HI @talhazengin, There are two ways:

    1. Get all tenants and change the current tenant to get their data:
    using (_currentTenant.Change(tenant.Id))
    {
          // query....
    }
    
    1. Disable multi-tenant filter:
    using (_dataFilter.Disable<IMultiTenant>())
    {
           // query....
    }
    
  • User Avatar
    0
    talhazengin created

    Hi @liangshiwei, Thank you, i choose second :)

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07