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.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    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....
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    talhazengin created

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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.