Connection must be opened on rollback and accent error

Re: Connection must be opened on rollback and accent error

Postby 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
concware
 
Posts: 14
Joined: Thu 09 Jan 2014 21:51

Re: Connection must be opened on rollback and accent error

Postby 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.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Connection must be opened on rollback and accent error

Postby concware » Tue 29 Jul 2014 20:26

The posted code worked for me.

Thanks your help!
concware
 
Posts: 14
Joined: Thu 09 Jan 2014 21:51

Previous

Return to dotConnect for PostgreSQL