Tried Postgres 9.6 and 10.0.
Test case:
Code: Select all
static Task Test_pgsql_distributed_transaction()
{
string conStr = "..;enlist=true;";
using (var tx = new TransactionScope())
{
var con1 = new Devart.Data.PostgreSql.PgSqlConnection();
var con2 = new Devart.Data.PostgreSql.PgSqlConnection();
con1.ConnectionString = conStr;
con1.Open();
con2.ConnectionString = conStr;
con2.Open();
var cmd1 = con1.CreateCommand();
cmd1.CommandText = "select 1";
var cmd2 = con2.CreateCommand();
cmd2.CommandText = "select 2";
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
Console.WriteLine($"DistributedIdentifier: {Transaction.Current.TransactionInformation.DistributedIdentifier}");
tx.Complete();
con1.Close();
con2.Close();
}
}
Output: 00000000-0000-0000-0000-000000000000
Also checked via PerfMon, there is no DTC transactions.
If change "Devart.Data.PostgreSql.PgSqlConnection" to "System.Data.SqlClient.SqlConnection" then a distributed transaction will be created and commited (a guid will be output).