2

Due to SQL Server's SavePoints feature (SqlTransaction.Save()), I would like to use SqlTransactions in a very limited fashion (I REALLY need this functionality) while still using ambient transactions in all other places. I realize that this means that this code (and dependencies) are now SQL Server-specific - this is fine. However, I'd still prefer to follow the preferred ambient transactions in all other places for best practice purposes. (If we need to move to Oracle or something, then we'll need to rework this part of our code but don't want to rework the entire codebase.)

Is it possible to get a current SqlTransaction from Transaction.Current (which returns an object of type System.Transactions.Transaction) or some other way? (I may be wrong but I am guessing that this is ultimately the object that implements ambient Transaction object at run-time)

(related but different question I'm currently working on if you need more info on why)

Community
  • 1
  • 1
Jaxidian
  • 13,081
  • 8
  • 83
  • 125
  • My research is showing that everybody says I shouldn't mix these and then give philosophical reasons why (harder to maintain, etc.). As far as I can tell, there isn't a technical reason why I shouldn't mix these. If somebody can provide that, then that would answer this question as well. – Jaxidian Aug 09 '11 at 13:07

1 Answers1

0

As far as I can tell, this simply cannot be done. Given that I'm getting no response to this, I'm marking this as the answer. I could, still, be wrong. I simply cannot figure this one out, though, and don't have the time to look into it any further.

Jaxidian
  • 13,081
  • 8
  • 83
  • 125