system.transactions

How to create a class that works with TransactionScope?

大憨熊 提交于 2019-12-03 05:36:30
问题 Just wondering, if I want to create a class that does something and I want to be able to be used in a TransactionScope, what would I need to implement? That is: My class needs to be aware that it's in a Transaction, but how would it get notified on Commit or Rollback? And on Rollback, how would I actually Rollback? I assume my class would have methods like "Add", "Update" and "Delete" which only modify a temporary list of changes, and a method "Read" which needs to detect if it is in a

Why is a nested transaction committed even if TransactionScope.Complete() is never called?

一世执手 提交于 2019-12-01 13:25:41
I was testing to see how nested transactions work, and uncovered this disturbing and unexpected behavior. using(TransactionScope otx = new TransactionScope()) using(SqlConnection conn1 = new SqlConnection("Server=S;Database=DB;Trusted_Connection=yes")) using(SqlCommand cmd1 = conn1.CreateCommand()) { conn1.Open(); cmd1.CommandType = CommandType.Text; cmd1.CommandText = "INSERT INTO FP.ACLs (ChangeToken,ACL) VALUES (1,0x)"; cmd1.ExecuteNonQuery(); using(TransactionScope itx = new TransactionScope(TransactionScopeOption.RequiresNew)) using(SqlConnection conn2 = new SqlConnection("Server=S

Why is a nested transaction committed even if TransactionScope.Complete() is never called?

血红的双手。 提交于 2019-12-01 10:16:01
问题 I was testing to see how nested transactions work, and uncovered this disturbing and unexpected behavior. using(TransactionScope otx = new TransactionScope()) using(SqlConnection conn1 = new SqlConnection("Server=S;Database=DB;Trusted_Connection=yes")) using(SqlCommand cmd1 = conn1.CreateCommand()) { conn1.Open(); cmd1.CommandType = CommandType.Text; cmd1.CommandText = "INSERT INTO FP.ACLs (ChangeToken,ACL) VALUES (1,0x)"; cmd1.ExecuteNonQuery(); using(TransactionScope itx = new

using TransactionScope : System.Transactions.TransactionAbortedException: The transaction has aborted

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 03:51:01
We're trying to do indirect nesting transaction using the code below, .NET 3.5 ,& SQL Server 2005. MSDN says that when using TransactionScope, a transaction is escalated whenever application opens a second connection (even to the same database) within the Transaction. void RootMethod() { using(TransactionScope scope = new TransactionScope()) { /* Perform transactional work here */ FirstMethod(); SecondMethod(); scope.Complete(); } } void FirstMethod() { using(TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { using (SqlConnection conn1 = new SqlConnection("Data

using TransactionScope : System.Transactions.TransactionAbortedException: The transaction has aborted

自古美人都是妖i 提交于 2019-12-01 00:39:39
问题 We're trying to do indirect nesting transaction using the code below, .NET 3.5 ,& SQL Server 2005. MSDN says that when using TransactionScope, a transaction is escalated whenever application opens a second connection (even to the same database) within the Transaction. void RootMethod() { using(TransactionScope scope = new TransactionScope()) { /* Perform transactional work here */ FirstMethod(); SecondMethod(); scope.Complete(); } } void FirstMethod() { using(TransactionScope scope = new

.net durable resource manager for transactional filesystem access

喜夏-厌秋 提交于 2019-11-29 10:28:16
I'm trying to wrap my head around the use of the System.Transactions namespace in C#. I've found some documentation on MSDN regarding using resource managers, but it only covers volatile, in-memory resource managers in any detail (like Transactional ). I'm basically looking for something that I can use inside of a TransactionScope, just like Transactional<> but use it for writing/modifying/deleting files on disk. Does something like this exist in the standard libs? I've read that NTFS has "TxF" now to allow transactional filesystem access - I was expecting to find something in .net that