We had hit an issue when using multi-tenancy (see sample below), when being a singleton.
Basically, we have something like the following small sample:
- Service A - singleton per tenant (
IHeroDataClient) - 2 different implementations per tenant
- Service B - singleton per tenant (
HerozClientSub) - same implementation but instance per tenant
- Service C - singleton for all (
IDataClientManager) - same instance for all tenants (shared)
In the above example if we remove Service B (HerozClientSub) it works, so basically when having nested singleton deps it doesn't resolve the tenant.
By changing Service A and Service B to scoped it will also work, but it's not ideal as it will create instances redundantly, and also not sure why it doesn't resolve or if it's intended or a bug.
This is the sample if you want to look at it:
Changes to cause the issue: sketch7/dotnet.multitenancy@feature/initial-imp...issue/nested-singleton-tenant-bug
Some interest points
Basically, the implementation of how tenancy works is how you had suggested.
Am I doing something wrong? should this work?
Thanks
We had hit an issue when using multi-tenancy (see sample below), when being a singleton.
Basically, we have something like the following small sample:
IHeroDataClient) - 2 different implementations per tenantHerozClientSub) - same implementation but instance per tenantIDataClientManager) - same instance for all tenants (shared)In the above example if we remove Service B (
HerozClientSub) it works, so basically when having nested singleton deps it doesn't resolve the tenant.By changing Service A and Service B to scoped it will also work, but it's not ideal as it will create instances redundantly, and also not sure why it doesn't resolve or if it's intended or a bug.
This is the sample if you want to look at it:
Changes to cause the issue: sketch7/dotnet.multitenancy@feature/initial-imp...issue/nested-singleton-tenant-bug
Some interest points
Basically, the implementation of how tenancy works is how you had suggested.
Am I doing something wrong? should this work?
Thanks