Where is "Enlist=false" conn string option?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
tylerburd
Posts: 3
Joined: Mon 28 Sep 2009 23:24

Where is "Enlist=false" conn string option?

Post by tylerburd » Mon 28 Sep 2009 23:29

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

Shalex
Site Admin
Posts: 8246
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 29 Sep 2009 10:21

The PgSqlConnection class includes the EnlistTransaction method, which enlists the connection in the specified transaction.

Code: Select all

[C#]
public override void EnlistTransaction( 
   Transaction 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#]
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();

tylerburd
Posts: 3
Joined: Mon 28 Sep 2009 23:24

Post by tylerburd » Tue 29 Sep 2009 18:18

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();
}

Shalex
Site Admin
Posts: 8246
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 30 Sep 2009 15:46

We will implement the Enlist parameter of the connection string. I will post here when this functionality is available.

Shalex
Site Admin
Posts: 8246
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 08 Oct 2009 11:54

The Enlist parameter is implemented. Look forward to the next build, which will be available in 2-3 weeks.

Shalex
Site Admin
Posts: 8246
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 20 Oct 2009 09:24

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 .

Post Reply