Connection must be opened on rollback and accent error

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
concware
Posts: 14
Joined: Thu 09 Jan 2014 21:51

Re: Connection must be opened on rollback and accent error

Post by concware » Mon 28 Jul 2014 21:28

I have reupload the sample project.

You can download it by the following url:
http://we.tl/fnQA1af8lB

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

Re: Connection must be opened on rollback and accent error

Post by Shalex » Tue 29 Jul 2014 11:31

Please open your \TransactionHandlingTest\DataAccessLayer\ModelTransaction.cs and replace

Code: Select all

        public DbTransaction BeginTransaction(System.Data.IsolationLevel isolation)
        {
            if (this.Database.Connection.State == ConnectionState.Closed)
                this.Database.Connection.Open();

            if (_transaction == null)
            {
                _transaction = this.Database.Connection.BeginTransaction(isolation);
                _numberOfTransactions = 1;
            }
            else
            {
                ++_numberOfTransactions;
            }

            return _transaction;
        }
with

Code: Select all

        public DbTransaction BeginTransaction(System.Data.IsolationLevel isolation)
        {
            var connection = ((System.Data.Entity.Infrastructure.IObjectContextAdapter)this).ObjectContext.Connection;
            if (connection.State == ConnectionState.Closed)
                connection.Open();

            if (_transaction == null)
            {
                _transaction = connection.BeginTransaction(isolation);
                _numberOfTransactions = 1;
            }
            else
            {
                ++_numberOfTransactions;
            }

            return _transaction;
        }
After this, your project should work. Notify us about the result.

concware
Posts: 14
Joined: Thu 09 Jan 2014 21:51

Re: Connection must be opened on rollback and accent error

Post by concware » Tue 29 Jul 2014 20:26

The posted code worked for me.

Thanks your help!

Post Reply