TransactionScope has several restrictions: 1. IsolationLevel can't change during transaction 2. Nested transaction scopes are not really what we know as nested transactions
Is it possible to write custom TransactionScope to workaround these restrictions or are they integrated into core of System.Transactions开发者_如何学JAVA and can't be changed?
Upd. If not why do people create custom TransactionScopes? What problems does it allow to solve?
Re your 2nd point (and reading the comment); indeed, the "one fail, everything rolls back immediately" is an inherent part of DTC; the entire outer transaction is the atomic unit. You might be able to use some regular SQL transactions inside the DTC transaction, but to be honest that is making things complex...
My suggestion:
- either write the SQL to succeed (i.e. on rollback if something gets very ill; not just for convenience of experimental queries)
- or: don't use DTC
and I prefer the first, as rollback is expensive (commit is cheap).
(I don't know definitively for your first point, but I believe that is pretty stone-like)
精彩评论