Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

[Ignore...Resolved] Manually add a filter on the tenant ID #8433


User avatar
0
rickfrankel created

Hi,

I have a situation where I need to disable the tenant filters and then optionally manually add a filter on the tenant ID.

I do it as follows.

Wrap my code in using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.MustHaveTenant, AbpDataFilters.MayHaveTenant)) {

Then do a var query = repo.GetAll() .Include(a bunch of related tables). etc

Further down in my logic with the IQueryable I will add in the following.

query.Where(_ => _.TenantId == AbpSession.TenantId.Value)

When I execute that query the TenantID filter is NOT enforced as I expect it to be.

The DisableFilter appears to overrule any manually added TenantId filter.

Is this expected? How do I get around this?

I feel like I'm missing something here.


No answer yet!