Implementing a Lightweight TransactionScope

ado.net c# dapper micro-orm transactionscope

Question

I'm referring to this SO question: Bulk inserts taking longer than expected using Dapper

and to this @SamSaffron comment to that question:

"TransactionScope does a bunch of DTC nonsense you generally do not care about, would avoid it unless I needed that feature, it is quite easy to roll your own context attached to thread local storage"

I know how to roll my own TransactionManager by using a transaction attached to a [ThreadStatic] variable, but is there some reliable way to emulate the TransactionScope so the commands will enlist automatically my transaction? The final product will be a transaction scope withour any MSDTC plumbing.

Accepted Answer

Yes, see my TextMetal project, the sample code, and pay attention to the Plumbing namespace. If you have questions, email me. No MSDTC slight of hand, just ADO.NET, a unit of work pattern, and some well engineered data access code!




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why