Commits

Inside Zhou  committed 601f8ce

InputPlan允许调用者将DbParameter作为输入对象的属性值。

  • Participants
  • Parent commits 72fb1af

Comments (0)

Files changed (1)

File Sql/InputPlan.cs

 					}
 				}
 				else {
-					valClause.Append(string.Format(":{0},", c.name));
-					var p = sql.CreateParameter();
-					p.ParameterName = c.name;
-					try {
-						p.Value = value;
+					if(value is DbParameter) {
+						var p = value as DbParameter;
+						valClause.Append(string.Format(":{0},", p.ParameterName));
+						parameters.Add(p);
 					}
-					catch(ArgumentException) {
-						throw new ArgumentException(string.Format("生成查询参数时出错。\nname : {0}\nvalue : {1}", c.name, value.ToString()));
+					else {
+						valClause.Append(string.Format(":{0},", c.name));
+
+						var p = sql.CreateParameter();
+						p.ParameterName = c.name;
+#if DEBUG
+						try {
+							p.Value = value;
+						}
+						catch(ArgumentException) {
+							throw new ArgumentException(string.Format("生成查询参数时出错。\nname : {0}\nvalue : {1}", c.name, value.ToString()));
+						}
+#else
+							p.Value = value;
+#endif
+						parameters.Add(p);
 					}
-					parameters.Add(p);
 				}
 			}
 			colClause.Remove(colClause.Length - 1, 1);
 					}
 				}
 				else {
-					setClause.Append(string.Format("{0} = :{0},", c.name));
-					var p = sql.CreateParameter();
-					p.ParameterName = c.name;
-					p.Value = value;
-					parameters.Add(p);
+					if(value is DbParameter) {
+						var p = value as DbParameter;
+						setClause.Append(string.Format("{0} = :{0},", p.ParameterName));
+						parameters.Add(p);
+					}
+					else {
+						setClause.Append(string.Format("{0} = :{0},", c.name));
+						var p = sql.CreateParameter();
+						p.ParameterName = c.name;
+#if DEBUG
+						try {
+							p.Value = value;
+						}
+						catch(ArgumentException) {
+							throw new ArgumentException(string.Format("生成查询参数时出错。\nname : {0}\nvalue : {1}", c.name, value.ToString()));
+						}
+#else
+							p.Value = value;
+#endif
+						parameters.Add(p);
+					}
 				}
 			}
 			setClause.Remove(setClause.Length - 1, 1);