Search code examples
aspnetboilerplate

Get records as host admin for all tenants in AspnetBoilerplate


I want to retrieve records when logged in as the host admin for all tenants.

await auditLogRepository.GetAll().ToListAsync();

This however will not return records for tenants however. AuditLog implements IMayHaveTenant which I think is causing this as anything that implements IMustHaveTenant returns all the records.

How can I select the AuditLogs for all tenants when logged in as the host admin (no tenant)?


Solution

  • You have to disable MayHaveTenant filter to retrieve all logs.

    using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
    {
        var allLogs = await auditLogRepository.GetAll().ToListAsync();                
    }
    

    see here for further info