Closed dtkujawski closed 3 years ago
I'll take a look later today, that seems like odd behavior considering the way singleton is implemented.
So you're running into the same issue where the container is trying to auto resolve the Sub type. I'll be honest I try and avoid child containers as they are not performant at all in terms of a per-request solution and I don't solve tenancy issues though DI.
I've put together a couple tests showing how to solve this type of issue using a lifetime scope which is much faster.
When I am using the main container, the following code works fine but doe not work when using a ChildScope. In this example I have a TOP class and a SUB class. The SUB class is an argument on the constructor of the TOP class. If I set SUB to a singleton, I expect that if I create multiple TOP instances, each should have the same instance of SUB in them.
Here are the simple classes
Example code from the container, this works fine:
However, when I use a ChildSope; it doesn't work for the TOP instances: