public DataSet GetDataset([NotNull] IDbCommand cmd, bool transaction) { using (var qc = new QueryCounter(cmd.CommandText)) { return(this.GetDatasetBasic(cmd, transaction)); } }
/// <summary> /// The execute scalar. /// </summary> /// <param name="cmd"> /// The cmd. /// </param> /// <param name="transaction"> /// The transaction. /// </param> /// <returns> /// The execute scalar. /// </returns> public object ExecuteScalar([NotNull] IDbCommand cmd, bool transaction) { using (var qc = new QueryCounter(cmd.CommandText)) { using (var connectionManager = this.GetConnectionManager()) { // get an open connection cmd.Connection = connectionManager.OpenDBConnection; Trace.WriteLine(cmd.ToDebugString(), "DbAccess"); if (transaction) { // get scalar using a transaction using (var trans = connectionManager.OpenDBConnection.BeginTransaction(_isolationLevel)) { cmd.Transaction = trans; object results = cmd.ExecuteScalar(); trans.Commit(); return(results); } } // get scalar regular return(cmd.ExecuteScalar()); } } }
/// <summary> /// The get data. /// </summary> /// <param name="cmd"> /// The cmd. /// </param> /// <param name="transaction"> /// The transaction. /// </param> /// <returns> /// </returns> public DataTable GetData([NotNull] IDbCommand cmd, bool transaction) { using (var qc = new QueryCounter(cmd.CommandText)) { return(this.ProcessUsingResultFilters(this.GetDatasetBasic(cmd, transaction).Tables[0], cmd.CommandText)); } }
/// <summary> /// The execute non query. /// </summary> /// <param name="cmd"> /// The cmd. /// </param> /// <param name="transaction"> /// The transaction. /// </param> public void ExecuteNonQuery([NotNull] IDbCommand cmd, bool transaction) { using (var qc = new QueryCounter(cmd.CommandText)) { using (var connectionManager = this.GetConnectionManager()) { // get an open connection cmd.Connection = connectionManager.OpenDBConnection; Trace.WriteLine(cmd.ToDebugString(), "DbAccess"); if (transaction) { // execute using a transaction using (var trans = connectionManager.OpenDBConnection.BeginTransaction(_isolationLevel)) { cmd.Transaction = trans; cmd.ExecuteNonQuery(); trans.Commit(); } } else { // don't use a transaction cmd.ExecuteNonQuery(); } } } }
/// <summary> /// The get data. /// </summary> /// <param name="commandText"> /// The command text. /// </param> /// <param name="transaction"> /// The transaction. /// </param> /// <returns> /// </returns> public DataTable GetData([NotNull] string commandText, bool transaction) { using (var qc = new QueryCounter(commandText)) { using (var cmd = new SqlCommand()) { cmd.CommandType = CommandType.Text; cmd.CommandText = commandText; return(this.ProcessUsingResultFilters(this.GetDatasetBasic(cmd, transaction).Tables[0], commandText)); } } }