Question about "Transactions in context values" #14
-
|
This is copy/paste of a thread on Twitter regarding the video I created covering the "queries pattern" (aka Transaction Script): Source: https://twitter.com/DevSomto/status/1829019268870004766
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Hi @MarioCarrion , Thank you for responding to my question. My question in the tweet was aimed at clarifying my understanding of the video. If I'm correct, you're using |
Beta Was this translation helpful? Give feedback.
Thanks for the context @codescratchers.
Now that you mentioned it, I should have used an HTTP handler to demonstrate what I meant because that's where this is typically useful.
In the video, I recommend the opposite: not using context to include the transaction but rather refactoring the underlying code that happens to need a transaction to use another type (the "transaction script") to drive this logic, to reuse existing repositories that can support transactions if required.
See
UserCloner.Clone, this method drives the transaction not the layers above it (like an HTTP handler). If you see the code for the used types (exampleUser) you will notice they refer to theDBTX typeso in practi…