Hi,
I have the following code:
[UnitOfWork]
public async Task GetFinancialConnector(AdministrationIdentifier administration)
{
var results1 = _administrationRepository.GetAllList(); // Returns all 8 administrations --> correct
UnitOfWorkManager.Current.SetTenantId(administration.TenantId);
var results2 = _administrationRepository.GetAllList(); // Returns 0 administrations --> incorrect!
UnitOfWorkManager.Current.SetTenantId(administration.TenantId);
var results3 = _administrationRepository.GetAllList(); // Returns all 8 administrations --> correct
}
Administration implements IMustHaveTenant. This method is called with a non null value for administration.TenantId, e.g. 1.
After calling SetTenantId the first time _administrationRepository.GetAllList() doesn't return any results. At this moment FilterParameter MustHaveTenant has no parameters, which is strange because SetTenantId was called before with a tenant id. After calling SetTenantId the second time _administrationRepository.GetAllList() returns the correct results. At this moment the parameter of MustHaveTenant is correctly set.
Can someone clarify why calling SetTenantId once doesn't give the desired result?
Note: this code is running in a console app. AbpSession.TenantId is null. If I register a custom IAbpSession and set TenantId to a non null value, calling SetTenantId once works perfectly.
Thanks.
Kind regards,
Nik