public QueryStore(string sql, ParameterStoreCollection parameters) { _sql = sql; Parameters = new ParameterStoreCollection(); foreach (ParameterStore p in parameters) { Parameters.Add(p.Clone()); } }
public static ParameterStoreCollection GetParameterStores(IDbCommand command, ParameterStoreCollection stores, out bool modified) { modified = false; ParameterStoreCollection l = new ParameterStoreCollection(); foreach (DbParameter p in command.Parameters) { ParameterStore ps = stores[p.ParameterName]; ParameterStore psAll = AllParameters[p.ParameterName]; if (ps != null) { ps = ps.Clone() as ParameterStore; ps.Target = p; } else if (psAll != null) { ps = psAll.Clone() as ParameterStore; ps.Target = p; modified = true; } else { ps = new ParameterStore(p); modified = true; } l.Add(ps); if (psAll != null) { ps.CopyTo(psAll); } else { AllParameters.Add(ps.Clone() as ParameterStore); } } return(l); }
public static ParameterStoreCollection GetParameterStores(string[] paramNames, ParameterStoreCollection stores, out bool modified) { modified = false; ParameterStoreCollection l = new ParameterStoreCollection(); foreach (string param in paramNames) { ParameterStore ps = stores[param]; ParameterStore psAll = AllParameters[param]; if (ps != null) { ps = ps.Clone() as ParameterStore; ps.Target = null; } else if (psAll != null) { ps = psAll.Clone() as ParameterStore; ps.Target = null; modified = true; } else { ps = new ParameterStore(param); modified = true; } l.Add(ps); if (psAll != null) { ps.CopyTo(psAll); } else { AllParameters.Add(ps.Clone() as ParameterStore); } } return(l); }
public QueryStore(TextReader reader) { StringBuilder buf = new StringBuilder(); for (string s = reader.ReadLine(); s != null && s.StartsWith(ParamSeparator); s = reader.ReadLine()) { buf.AppendLine(s); } _sql = buf.ToString(); Parameters = new ParameterStoreCollection(); while (reader.Peek() != -1) { string pName = GetWord(reader, false); if (pName == null) { break; } if (pName.StartsWith(ParamSeparator)) { return; } if (!pName.StartsWith("--")) { throw new ApplicationException("パラメータ宣言が -- で開始されていません"); } if (pName == "--") { pName = GetWord(reader, false); } else { pName = pName.Substring(2); } string s = GetWord(reader, false); if (s == null || s != ":") { throw new ApplicationException(":が見つかりません"); } string typeStr = GetWord(reader, false); s = GetWord(reader, false); if (s == null || s != "=") { throw new ApplicationException("=が見つかりません"); } string val = GetWord(reader, true); ParameterStore param = new ParameterStore(pName); DbTypeInfo info = DbTypeInfo.GetDbTypeInfo(typeStr); if (info == null) { throw new ApplicationException(string.Format("不明な型です: {0}", typeStr)); } param.DbType = info.DbType; if (string.IsNullOrEmpty(val) || string.Compare(val, "null", true) == 0) { param.Value = DBNull.Value; } else { val = DequoteStr(val); param.Value = info.Parse(val); } Parameters.Add(param); } }