I have reupload the sample project.
You can download it by the following url:
http://we.tl/fnQA1af8lB
Connection must be opened on rollback and accent error
Re: Connection must be opened on rollback and accent error
Please open your \TransactionHandlingTest\DataAccessLayer\ModelTransaction.cs and replace
with
After this, your project should work. Notify us about the result.
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;
}
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;
}
Re: Connection must be opened on rollback and accent error
The posted code worked for me.
Thanks your help!
Thanks your help!