数组绑定更新C#Oracle

时间:2018-09-06 11:46:58

标签: c# oracle save dapper

我正在尝试使用C#更新oracle表,我有一个表 Table

我有一个新的数据集合(表的所有元素还包括具有更改的项目)。 Saver

我如何使用数组绑定更新表,以更新每个列。

这是我无效的更新版本

OracleCommand cmd = connection.CreateCommand();
cmd.CommandText = "Update T_PEO_GAS_FACTOR_Y " +
                  "Set V_M01 =:v_m1, " +
                  "V_M02 =:v_m2, " +
                  "V_M03 =:v_m3, " +
                  "V_M04 =:v_m4, " +
                  "V_M05 =:v_m5, " +
                  "V_M06 =:v_m6, " +
                  "V_M07 =:v_m7, " +
                  "V_M08 =:v_m8, " +
                  "V_M09 =:v_m9, " +
                  "V_M10 =:v_m10, " +
                  "V_M11 =:v_m11, " +
                  "V_M12 =:v_m12 " +
                  "where (CALENDAR_YEAR=:year and FORECAST_VERSION_ID=:forecastVer and PEO_VERSION_ID=:peoVer)";
//1
cmd.Parameters.Add("v_m1", OracleDbType.Decimal);
cmd.Parameters["v_m1"].Value = 228;
//2
cmd.Parameters.Add("v_m2", OracleDbType.Decimal);
cmd.Parameters["v_m2"].Value = 228;
//3
cmd.Parameters.Add("v_m3", OracleDbType.Decimal);
cmd.Parameters["v_m3"].Value = 228;
//4
cmd.Parameters.Add("v_m4", OracleDbType.Decimal);
cmd.Parameters["v_m4"].Value = 228;
//5
cmd.Parameters.Add("v_m5", OracleDbType.Decimal);
cmd.Parameters["v_m5"].Value = 228;
//6
cmd.Parameters.Add("v_m6", OracleDbType.Decimal);
cmd.Parameters["v_m6"].Value = 228;
//7
cmd.Parameters.Add("v_m7", OracleDbType.Decimal);
cmd.Parameters["v_m7"].Value = 228;
//8
cmd.Parameters.Add("v_m8", OracleDbType.Decimal);
cmd.Parameters["v_m8"].Value = 228;
//9
cmd.Parameters.Add("v_m9", OracleDbType.Decimal);
cmd.Parameters["v_m9"].Value = 228;
//10
cmd.Parameters.Add("v_m10", OracleDbType.Decimal);
cmd.Parameters["v_m10"].Value = 228;
//11
cmd.Parameters.Add("v_m11", OracleDbType.Decimal);
cmd.Parameters["v_m11"].Value = 228;
//12
cmd.Parameters.Add("v_m12", OracleDbType.Decimal);
cmd.Parameters["v_m12"].Value = 228;

//остальные параметры
cmd.Parameters.Add("year", OracleDbType.Decimal);
cmd.Parameters["year"].Value = 2016;
cmd.Parameters.Add("forecastVer", OracleDbType.Decimal);
cmd.Parameters["forecastVer"].Value = 2684;
cmd.Parameters.Add("peoVer", OracleDbType.Decimal);
cmd.Parameters["peoVer"].Value = 81114;

0 个答案:

没有答案