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

Get a setting value for all tenants #8268


User avatar
0
ajayak created

Hi,

I have a background job where I fetch a setting value for each tenant. Is there a way by which I can fetch the setting value for all tenants in 1 query instead of foreach?

Current code:

var tenantIds = await _lRepository.GetAll().IgnoreQueryFilters()
    .Select(c => c.TenantId)
    .ToListAsync();
foreach (var tenantId in tenantIds)
{
    var myBoolFlag = await SettingManager.GetSettingValueForTenantAsync<bool>("Super Power", tenantId);
    if (!myBoolFlag) continue;

    // Other code
}

1 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, you can query directly from setting repository.

    IRepository<Setting, long> settingRepository;