public void CanGetParametersForStoredProcedure() { cache.SetParameters(storedProcedure, db); Assert.AreEqual(2, storedProcedure.Parameters.Count); Assert.AreEqual("CUR_OUT", ((IDataParameter)storedProcedure.Parameters["CUR_OUT"]).ParameterName); Assert.AreEqual("VCUSTOMERID", ((IDataParameter)storedProcedure.Parameters["VCUSTOMERID"]).ParameterName); }
public void CanGetParametersForStoredProcedure() { cache.SetParameters(storedProcedure, db); Assert.AreEqual(2, storedProcedure.Parameters.Count); Assert.AreEqual("@RETURN_VALUE", ((IDataParameter)storedProcedure.Parameters["@RETURN_VALUE"]).ParameterName); Assert.AreEqual("@CustomerID", ((IDataParameter)storedProcedure.Parameters["@CustomerId"]).ParameterName); }
private static DbCommand GetDbCommand(Database database, string storedProcedureName, params KeyValueItem[] parameterValues) { if (parameterValues == null) { throw new ArgumentNullException("parameterValues"); } DbCommand cmd = database.GetStoredProcCommand(storedProcedureName); cache.SetParameters(cmd, database); for (int i = 0; i < cmd.Parameters.Count; i++) { bool flag = false; for (int j = 0; j < parameterValues.Length; j++) { if (parameterValues[j].Key.ToUpper().Equals(cmd.Parameters[i].ParameterName.ToUpper())) { database.SetParameterValue(cmd, cmd.Parameters[i].ParameterName, parameterValues[j].Value); flag = true; break; } } if (!flag) { database.SetParameterValue(cmd, cmd.Parameters[i].ParameterName, Convert.DBNull); } } return(cmd); }
protected DbCommand GetCommand(String cmd, Database db) { DbCommand res = db.GetStoredProcCommand(cmd); parameterCache.SetParameters(res, db); return(res); }