/// <summary> /// Runs a command and returns a DataTable containing its results. /// </summary> /// <param name="db">Open data connection</param> /// <param name="sqlstr">SQL string</param> /// <param name="_params">List of parameters to use with the SQL</param> public static DataTable ExecuteDataTable(this DbTransaction tran, string sqlstr, IEnumerable <IDataParameter> _params) { IDataReader reader = tran.ExecuteReader(sqlstr, _params.ToArray()); DataTable result = new DataTable(); result.Load(reader); return(result); }
/// <summary> /// Runs a command and returns a DataTable containing its results. /// </summary> /// <param name="db">Open data connection</param> /// <param name="sqlstr">SQL string</param> /// <param name="_params">List of parameters to use with the SQL</param> public static DataTable ExecuteDataTable(this DbTransaction tran, string sqlstr, params IDataParameter[] _params) { IDataReader reader = tran.ExecuteReader(sqlstr, _params); DataTable result = new DataTable(); result.Load(reader); return(result); }
///<summary>Executes a SQL statement against a connection.</summary> ///<param name="transaction">The transaction to the database. The connection is not closed.</param> ///<param name="sql">The SQL to execute.</param> ///<returns>A DbDataReader object, which will close its underlying connection when disposed.</returns> public static DbDataReader ExecuteReader(this DbTransaction transaction, string sql) { return(transaction.ExecuteReader <object>(sql, null)); }
public static List <T> ExecuteCollection <T>(this DbTransaction tran, string sqlstr, Func <IDataRecord, T> collector, params IDataParameter[] _params) { return(tran.ExecuteReader(sqlstr, _params).Collect(collector)); }
/// <summary> /// Runs a command and returns a reader that iterates its results. /// </summary> /// <param name="db">Open data connection</param> /// <param name="sqlstr">SQL string</param> /// <param name="_params">List of parameters to use with the SQL</param> public static IDataReader ExecuteReader(this DbTransaction tran, string sqlstr, IEnumerable <IDataParameter> _params) { return(tran.ExecuteReader(sqlstr, _params.ToArray())); }