Allow local transaction to enlist in TransactionScope
Posted: Thu 01 Oct 2009 05:39
I want to start using TransactionScope in an existing project. This project already makes heavy use of local transactions, and when I try to open a local transaction within a TransactionScope dotConnect throws an error, saying this is an invalid operation. This is contradictory to other db drivers, like Npgsql or the built in .Net drivers for SQL Server.
This definitely prevents us from implementing this new feature in existing projects. Can this be fixed?
Here is a simple example of the problem. When conn.BeginTransaction() is called an error is thrown.
This definitely prevents us from implementing this new feature in existing projects. Can this be fixed?
Here is a simple example of the problem. When conn.BeginTransaction() is called an error is thrown.
Code: Select all
var conn = new PgSqlConnection("...");
using (var scope = new TransactionScope())
{
conn.Open();
using (var localTx = conn.BeginTransaction())
{
var cmd = conn.CreateCommand();
cmd.CommandText = "INSERT INTO TestTable (1)";
cmd.Transaction = localTx;
localTx.Commit();
}
scope.Complete();
}