И опять MySQL, TransactionScope & BLT
От: MozgC США http://nightcoder.livejournal.com
Дата: 08.06.09 18:12
Оценка:
Здравствуйте,

Есть простой тест:

[Test]
public void TransactionScopeTest()
{
    using (new TransactionScope())
    {
        using (var db = new DbManager())
        {
            db.SetSpCommand("GetAllCustomers");
        }
    } 
}

Вылетает:

FreeTests.TransactionScopeTest : FailedDbManager: Operation 'OpenConnection' throws exception 'BLToolkit.Data.DataException: Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported. ---> System.NotSupportedException: Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.
at MySql.Data.MySqlClient.MySqlConnection.Open() in c:\VCProjects\MySQL Connector .NET 6.0.3\MySql.Data\Provider\Source\Connection.cs:line 454
at BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation) in c:\VCProjects\BLToolkit\Source\Data\DbManager.cs:line 4002
--- End of inner exception stack trace ---'

System.NotSupportedException: Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.
at MySql.Data.MySqlClient.MySqlConnection.Open() in Connection.cs: line 454
at BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation) in DbManager.cs: line 4002
BLToolkit.Data.DataException: Multiple simultaneous connections or connections with different connection strings inside the same transaction are not currently supported.
at BLToolkit.Data.DbManager.OnOperationException(OperationType op, DataException ex) in DbManager.cs: line 530
at BLToolkit.Data.DbManager.HandleOperationException(OperationType op, Exception ex) in DbManager.cs: line 4047
at BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation) in DbManager.cs: line 4007
at BLToolkit.Data.DbManager.DiscoverSpParameters(String spName, Boolean includeReturnValueParameter) in DbManager.cs: line 768
at BLToolkit.Data.DbManager.GetSpParameters(String spName, Boolean includeReturnValueParameter) in DbManager.cs: line 846
at BLToolkit.Data.DbManager.CreateSpParameters(String spName, Object[] parameterValues) in DbManager.cs: line 561
at BLToolkit.Data.DbManager.SetSpCommand(CommandAction commandAction, String spName, Object[] parameterValues) in DbManager.cs: line 1802
at BLToolkit.Data.DbManager.SetSpCommand(String spName, Object[] parameterValues) in DbManager.cs: line 1878
at RA.Tests.FreeTests.TransactionScopeTest() in FreeTests.cs: line 39


Ключевые вызовы: DiscoverSpParameters() -> ExecuteOperation(OperationType.OpenConnection, con.Open); -> и дальше уже в MySqlConnection.Open() (MySql.Data.MySqlClient namespace) есть такой участок:

// if we are auto enlisting in a current transaction, then we will be
// treating the connection as pooled
if (settings.AutoEnlist && Transaction.Current != null)
{
  driver = DriverTransactionManager.GetDriverInTransaction(Transaction.Current);
  if (driver != null &&
     (driver.IsInActiveUse ||
     !driver.Settings.EquivalentTo(this.Settings)))
       throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
}

driver.IsInActiveUse = true, поэтому выбрасывается исключение.

Any comments, suggestions, help?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.