public SqlStatement GetSqlStatement(string sqlStr, params object[] os) { CommandType ct = SqlStatement.GetCommandType(sqlStr); if (ct == CommandType.StoredProcedure) { return(new SqlStatement(ct, sqlStr, os)); } var dpc = new DataParameterCollection(); int start = 0, n = 0; var sql = new StringBuilder(); foreach (Match m in Reg.Matches(sqlStr)) { if (m.Length == 1) { string pn = Dialect.QuoteParameter("p" + n); sql.Append(sqlStr.Substring(start, m.Index - start)); sql.Append(pn); start = m.Index + 1; var dp = new DataParameter(pn, os[n]); dpc.Add(dp); n++; } } if (start < sqlStr.Length) { sql.Append(sqlStr.Substring(start)); } var ret = new SqlStatement(ct, sql.ToString(), dpc); return(ret); }
public SqlStatement GetSqlStatement(string sqlStr, params object[] os) { CommandType ct = SqlStatement.GetCommandType(sqlStr); if (ct == CommandType.StoredProcedure) { return new SqlStatement(ct, sqlStr, os); } var dpc = new DataParameterCollection(); int start = 0, n = 0; var sql = new StringBuilder(); foreach (Match m in Reg.Matches(sqlStr)) { if (m.Length == 1) { string pn = Dialect.QuoteParameter("p" + n); sql.Append(sqlStr.Substring(start, m.Index - start)); sql.Append(pn); start = m.Index + 1; var dp = new DataParameter(pn, os[n]); dpc.Add(dp); n++; } } if (start < sqlStr.Length) { sql.Append(sqlStr.Substring(start)); } var ret = new SqlStatement(ct, sql.ToString(), dpc); return ret; }
public SqlStatement(CommandType sqlCommandType, string sqlCommandText, params object[] os) : this(sqlCommandType, sqlCommandText) { Parameters.Add(os); }
protected virtual string GetValueString(DataParameterCollection dpc, DbDialect dd, KeyValue kv) { if(kv.Value == null) { return "NULL"; } string dpStr; if (DataSettings.UsingParameter) { dpStr = dd.QuoteParameter(string.Format("{0}_{1}", DataParameter.LegalKey(kv.Key), dpc.Count)); var dp = new DataParameter(dpStr, kv.NullableValue, kv.ValueType); dpc.Add(dp); } else { dpStr = DataTypeParser.ParseToString(kv.Value, dd); } return dpStr; }