/// <summary> /// Executes the specified SQL statement using the specified connection. /// </summary> /// <typeparam name="T">The type of object that the handler returns</typeparam> /// <param name="conn">The connection to use for the query call.</param> /// <param name="query">The SQL statement to execute.</param> /// <param name="rsh">The handler used to create the result object from the ResultSet.</param> /// <returns>An object generated by the handler.</returns> public T Query <T>(DbConnection conn, StringBuilder query, ResultSetHandler <T> rsh) { CheckNulls(conn, query); T result = default(T); DbCommand cmd = null; DbDataReader rd = null; try { cmd = conn.CreateCommand(); cmd.CommandText = query.ToString(); rd = cmd.ExecuteReader(); result = rsh.Handle(rd); } finally { Close(conn, cmd, rd); } return(result); }
/// <summary> /// Executes the specified statement using the specified connection. /// </summary> /// <typeparam name="T">The type of object that the handler returns</typeparam> /// <param name="conn">The connection to use for the query call.</param> /// <param name="stmtWrapper">The statement wrapper containing the query to execute and the statement params.</param> /// <param name="rsh">The handler used to create the result object from the ResultSet.</param> /// <returns>An object generated by the handler.</returns> public T Query <T>(DbConnection conn, StatementWrapper stmtWrapper, ResultSetHandler <T> rsh) { CheckNulls(conn, stmtWrapper.Query); T result = default(T); DbCommand cmd = null; DbDataReader rd = null; try { cmd = conn.CreateCommand(); cmd.CommandText = stmtWrapper.Query.ToString(); SetParameters(cmd, stmtWrapper.DBParams); rd = cmd.ExecuteReader(); result = rsh.Handle(rd); } finally { Close(conn, cmd, rd); } return(result); }