TransactionScope and DataContext

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Settler
Posts: 19
Joined: Mon 01 Mar 2010 16:32

TransactionScope and DataContext

Post by Settler » Mon 22 Mar 2010 15:55

Hello.

I'm try to use TransactionScope with generated data context like this:

Code: Select all

using(var scope = new TransactionScope())
{
    using(var context = new MyDataContext())
    {
         context.Tests.InsertOnSubmit(new Test());
         context.SubmitChanges();
         scope.Complete();
    }
}
But when "using scope" block is exit I catch TransactionAbortedException. What do I wrong here? Or how can I use TransactionScope with Devart.Data.Linq.DataContext?

For example this code block is working:

Code: Select all

using (var context = new MyDataContext())
            {
                try
                {
                    context.Tests.InsertOnSubmit(new Test());

                    context.Connection.Open();
                    context.Transaction = context.Connection.BeginTransaction();
                    context.SubmitChanges();
                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
            }
dotConnect for PostgreSQL: 4.65.79.0

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

Post by Shalex » Tue 23 Mar 2010 18:03

We have reproduced the mentioned behaviour. We will investigate this issue and notify you about the results as soon as possible.

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

Post by Shalex » Tue 13 Apr 2010 11:31

Please check the postgresql.conf file of your PostgreSQL server. There should be set the max_prepared_transactions parameter (zero disables the feature):

max_prepared_transactions = 15 # can be 0 or more

Change requires restart.

Post Reply