Why is a new DI scope created when using LocalProxy #2778
-
Currently, the If it is defaulted to true, then presumably that is the recommended path. What was the original problem that the new scope solves? If I can understand that, then I should be able to understand the consequences of setting the option to false. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I think it's so that you can create things like database connections and data store contexts and have them used across all of the objects in an object graph. If a parent creates a connection, then using that same connection for all of the children, grandchildren and so on is really useful. Reuse of the same connection/context avoids any attempt to perform escalation to a distributed transaction. Avoiding escalation is not only an efficiency gain, it's vital in .NET Core. .NET Core suffers from the hidden .NET Standard fib: that PlatformNotSupportedException is an allowed implementation of an API. Sigh. .NET Core runtimes throw PlatformNotSupportedException during an attempt to escalate a standard transaction to a distributed one. Despite distributed transactions looking like they should work because the moving parts are part of the .NET Standard API surface, they are not implemented on .NET Core, even after all of this time. There's an issue in the dotnet repo that tracks this problem. It has had an update suggesting this will be fixed (on Windows only) in .NET 7.0. However, the issue has been around long enough - and we've been batted away frequently enough - that I will wait and see rather than assume it'll happen. Indeed, this issue replaces several others that have simply been rejected as too difficult, and closed. It's been a bit of a hot potato. dotnet/runtime#715 |
Beta Was this translation helpful? Give feedback.
I think it's so that you can create things like database connections and data store contexts and have them used across all of the objects in an object graph. If a parent creates a connection, then using that same connection for all of the children, grandchildren and so on is really useful. Reuse of the same connection/context avoids any attempt to perform escalation to a distributed transaction.
Avoiding escalation is not only an efficiency gain, it's vital in .NET Core. .NET Core suffers from the hidden .NET Standard fib: that PlatformNotSupportedException is an allowed implementation of an API. Sigh. .NET Core runtimes throw PlatformNotSupportedException during an attempt to escalate a …