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

SetTenantId Issue #1775


User avatar
0
JeffMH created

I am on v0.9.6 of the framework:

I am running this code and when I run it, the IMustHaveTenant filter is not getting reset properly on exit of the Using.

using (UnitOfWorkManager.Current.SetTenantId(null))
{
    result = _tenantRepository.Get(tenantId.Value);
}

UnitOfWorkManager.Current.SetTenantId(tenantId.Value);

Before I execute the using, there is one FilterParameters in the MustHaveTenant data filter with tenantId = 7. Upon calling SetTenantId(Null), the filter parameter value tenantId turns to 0 as expected. Immediately after the using block, the MustHaveTenant FilterParameters is removed, there is no parameters in the data filter. I expect this to turn back to the way it was before I called SetTenantId(null). This is causing my next get from a MustHaveTenant table to fail because it passes Zero as the parameter value to Sql.

Right now, I am working around the issue by calling the SetTenantId(tenantId.value). This sets the parameters back to the way it was. But, I shouldn't need to call that. This is actually causing me several issues throughout the application.

I looked through the current code on GitHub and I don't see anything that jumps out at me as though it has changed in the latest version of the BaseUnitOfWork.

Here is a video of what is happening:

[https://1drv.ms/v/s!Am91meCOztkro7p10v62y081S_XS_w])

Thanks!


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi JeffMH,

    We have fixed this issue in v0.10. See the related bug: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1163">https://github.com/aspnetboilerplate/as ... ssues/1163</a> It's the same problem with yours. You can upgrade to v0.10, or better upgrade to v1.0.

  • User Avatar
    0
    JeffMH created

    Thanks for the prompt reply!