/// <summary> /// Opens a database connection and begins a new transaction with the specified transaction name /// and isolationLevel that is disposed when the returned object is disposed. /// </summary> /// <param name="connection">The connection to open.</param> /// <param name="isolationLevel">Specifies the isolation level for the transaction.</param> /// <param name="transactionName">Name for the transaction.</param> /// <returns>A wrapper for the database connection.</returns> public static DbConnectionWrapper OpenWithTransaction(this SqlConnection connection, IsolationLevel isolationLevel, string transactionName) { var wrapper = new DbConnectionWrapper(connection); wrapper.Open(); var transaction = connection.BeginTransaction(isolationLevel, transactionName); wrapper.UsingTransaction(transaction); return(wrapper); }
/// <summary> /// Initializes a new instance of the DbCommandWrapper class, and bind it to the specified ReliableConnection and innerCommand. /// </summary> /// <param name="innerConnection">The innerConnection to bind to.</param> /// <param name="innerCommand">The innerCommand to bind to.</param> public DbCommandWrapper(DbConnectionWrapper innerConnection, DbCommand innerCommand) { InnerConnection = innerConnection; InnerCommand = innerCommand; }