2

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.

Community
  • 1
  • 1
Felice Pollano
  • 32,832
  • 9
  • 75
  • 115

1 Answers1

1

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!

  • +1 it is a nice and interesting implementation, but ( may be I'm wrong) I can have more than one transaction in a single unit of work. If I get your code properly you have a one by one relation wit uow and transaction. hanks anyway, mor einterested in hacking the transaction scope class – Felice Pollano Aug 22 '12 at 18:58
  • A unit of work by definition implies one transaction. Sounds like what you are really saying is that you have multiple connections to data sources in a single unit of work, thus you need distributed transactions. My implementation assumes no MSDTC transactions. – Daniel P. Bullington Sep 12 '12 at 17:32