Exemple #1
0
 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);
 }
Exemple #2
0
 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);
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        protected DbCommand GetCommand(String cmd, Database db)
        {
            DbCommand res = db.GetStoredProcCommand(cmd);

            parameterCache.SetParameters(res, db);

            return(res);
        }