I'm trying to set up a local db transaction within a System.Transactions.TransactionScope. I do not want this transaction to take part in the TransactionScope. With other DB drivers you can do this by specifying "Enlist=false" on the connection string. I cannot find any such feature in dotConnect for PostgreSQL. Am I missing something? Will this be added in a future build?
Thank you,
Tyler Burd
Where is "Enlist=false" conn string option?
The PgSqlConnection class includes the EnlistTransaction method, which enlists the connection in the specified transaction.
Parameters
transaction
A reference to an existing System.Transactions.Transaction in which to enlist.
Remarks
Once a connection is explicitly enlisted in a distributed transaction, it cannot be unenlisted or enlisted in another transaction until the first transaction finishes.
Example
These samples demonstrate usage of EnlistTransaction.
Code: Select all
[C#]
public override void EnlistTransaction(
Transaction transaction
);
transaction
A reference to an existing System.Transactions.Transaction in which to enlist.
Remarks
Once a connection is explicitly enlisted in a distributed transaction, it cannot be unenlisted or enlisted in another transaction until the first transaction finishes.
Example
These samples demonstrate usage of EnlistTransaction.
Code: Select all
[C#]
pgSqlCommand1.Connection=pgSqlConnection1;
using (TransactionScope transScope = new TransactionScope()) {
pgSqlConnection1.Open();
pgSqlCommand1.ExecuteNonQuery();
transScope.Complete();
}
pgSqlConnection1.Close();
- or -
pgSqlCommand1.Connection=pgSqlConnection1;
pgSqlConnection1.Open();
using (TransactionScope transScope = new TransactionScope()) {
pgSqlConnection1.EnlistTransaction(Transaction.Current);
pgSqlCommand1.ExecuteNonQuery();
transScope.Complete();
}
pgSqlConnection1.Close();
- or -
CommittableTransaction cmtTx = new CommittableTransaction();
pgSqlConnection1.Open();
pgSqlConnection1.EnlistTransaction(cmtTx);
pgSqlCommand1.ExecuteNonQuery();
pgSqlConnection1.Close();
I understand that, but I would like to open a *new* connection and not enlist it in the TransactionScope at all.
var connectionThatShouldBeEnlisted = new PgsqlConnection(...);
var connectionNOTEnlisted = new PgsqlConnection(???);
using (TransactionScope transScope = new TransactionScope()) {
connectionThatShouldBeEnlisted.Open(); //want this one enlisted.
connectionNOTEnlisted.Open(); //I want this to NOT be enlisted.
...
transScope.Complete();
}
var connectionThatShouldBeEnlisted = new PgsqlConnection(...);
var connectionNOTEnlisted = new PgsqlConnection(???);
using (TransactionScope transScope = new TransactionScope()) {
connectionThatShouldBeEnlisted.Open(); //want this one enlisted.
connectionNOTEnlisted.Open(); //I want this to NOT be enlisted.
...
transScope.Complete();
}
The new build of dotConnect for PostgreSQL 4.55.49 is available for download now.
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=16153 .
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=16153 .