Open Closed

SetTenantId Issue #1775

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);


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:



2 Answer(s)
  • 0
    hikalkan created
    Support Team

    Hi JeffMH,

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

  • 0
    jeffmh created

    Thanks for the prompt reply!