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)