TransactionScope automatically escalating to MSDTC on some machines?

SQL Server 2008 can use multiple SQLConnections in one TransactionScope without escalating, provided the connections are not open at the same time, which would result in multiple “physical” TCP connections and thus require escalation. I see some of your developers have SQL Server 2005 and others have SQL Server 2008. Are you sure you have … Read more

PHP + MySQL transactions examples

The idea I generally use when working with transactions looks like this (semi-pseudo-code): try { // First of all, let’s begin a transaction $db->beginTransaction(); // A set of queries; if one fails, an exception should be thrown $db->query(‘first query’); $db->query(‘second query’); $db->query(‘third query’); // If we arrive here, it means that no exception was thrown … Read more

Using Transactions or SaveChanges(false) and AcceptAllChanges()?

With the Entity Framework most of the time SaveChanges() is sufficient. This creates a transaction, or enlists in any ambient transaction, and does all the necessary work in that transaction. Sometimes though the SaveChanges(false) + AcceptAllChanges() pairing is useful. The most useful place for this is in situations where you want to do a distributed … Read more

SqlException from Entity Framework – New transaction is not allowed because there are other threads running in the session

After much pulling out of hair I discovered that the foreach loops were the culprits. What needs to happen is to call EF but return it into an IList<T> of that target type then loop on the IList<T>. Example: IList<Client> clientList = from a in _dbFeed.Client.Include(“Auto”) select a; foreach (RivWorks.Model.NegotiationAutos.Client client in clientList) { var … Read more

tech