MRCollective/ReliableDbProvider — pull request #11 by BlairAlegroTech (2014-07-06 08:52:23+00:00)
Title: Bug Fix : Failure when executing SQL string  #7

The reason for this code failing was that the **ReliableConnection** of the Command was not being set in the constructor when the **ReliableSqlDbComand** was being constructed with a command that already has an associated Connection. To overcome this issue i have added a second constructor that takes a, SQLCommand and a ReliableSqlDbConnection *(Which is just the wrapped version of the existing commands connection)*.

//Bug Fix: Failure when executing SQL string
public ReliableSqlCommand(ReliableSqlDbConnection connection, SqlCommand commandToWrap)
{
this.Current = commandToWrap;
this.ReliableDbConnection = connection;
this.ReliableConnection = (connection==null) ? null : connection.ReliableConnection;
}

Also added a wrapper for transaction as returning a SqlTransaction allows a SQL connection to be leaked out of this wrapper.
This causes problems when using other API's such as EnterpriseLibrary.Data, as the leaked SQLConnection meant that the API had access to and used a *non-reliable* SqlConnection.