public abstract SetParametersOnCommand ( IDbCommand cmd, IEnumerable parameters ) : void | ||
cmd | IDbCommand | Database command (with .Text already populated with sql) that needs /// the parameters set on it. |
parameters | IEnumerable | The parameter values, in the order that the ?'s appear in the /// command's text. This collection should not be null. |
return | void |
/// <summary> /// Helper to set up a command with sql and parameters and other misc stuff. /// </summary> private static void SetSQLOnCommand(AbstractSqlConnectionDescriptor connDesc, IDbCommand cmd, string sql, IEnumerable sqlParams) { if (connDesc == null) { throw new ArgumentNullException("connDesc", "Connection descriptor cannot be null."); } if (cmd == null) { throw new ArgumentNullException("cmd", "Command cannot be null."); } try { cmd.CommandType = CommandType.Text; cmd.CommandText = sql; if (sqlParams != null) { connDesc.SetParametersOnCommand(cmd, sqlParams); } } catch (Exception e) { _log.Warn("Unable to set parameters on sql command, " + SqlUtilities.SqlParamsToString(sql, sqlParams), e); throw new ApplicationException("Bad parameters for sql statement.", e); } }