public override string ToString() { if (i == null) { return(null); } var parts = i.ToString().Split('?'); var result = new StringBuilder(parts[0]); var counter = 0; foreach (var p in i.GetParameters()) { counter++; if (p == null) { result.Append("null"); } else { var format = "{0}"; if (p is DateTime || p is Guid || p is string) { format = "'{0}'"; } result.AppendFormat(format, p); } if (counter < parts.Length) { result.Append(parts[counter]); } } return(result.ToString()); }
private string GetSqlWithParameters() { var sql = instruction.ToString(); var parameters = instruction.GetParameters(); var sb = new StringBuilder(); var i = 0; foreach (var part in sql.Split('?')) { sb.Append(part); if (i < parameters.Length) { var p = parameters[i]; if (p == null) { sb.Append("null"); } else if (p is string || p is char || p is DateTime || p is Guid) { sb.AppendFormat("'{0}'", p); } else { sb.Append(p); } } i++; } return(sb.ToString()); }
private string GetSqlWithParameters() { var sql = instruction.ToString(); var parameters = instruction.GetParameters(); var sb = new StringBuilder(); var i = 0; var sqlParts = sql.Split('?'); var pCount = parameters.Count(); foreach (var p in parameters) { sb.Append(sqlParts[i]); if (i < pCount) { if (p == null) { sb.Append("null"); } else if (p is string || p is char || p is DateTime || p is Guid) { sb.AppendFormat("'{0}'", p); } else { sb.Append(p); } } i++; } return(sb.ToString()); }
private IDbCommand CreateCommand(ISqlInstruction sql) { var command = GetConnection().CreateCommand(); var parameters = sql.GetParameters().ToArray(); var parts = sql.ToString(dialect).Split('?'); var result = new StringBuilder(); for (var i = 0; i < parts.Length - 1; i++) { var p = command.CreateParameter(); p.ParameterName = "p" + i; if (parameters[i] == null) { p.Value = DBNull.Value; } else if (parameters[i] is Enum) { p.Value = ((Enum)parameters[i]).ToString("d"); } else { p.Value = parameters[i]; } command.Parameters.Add(p); result.AppendFormat("{0}@{1}", parts[i], p.ParameterName); } result.Append(parts[parts.Length - 1]); command.CommandText = result.ToString(); return(command); }
public override object[] GetParameters() { var parameters = new List <object>(); parameters.AddRange(_condition.GetParameters()); parameters.AddRange(new[] { _trueValue, _falseValue }); return(parameters.ToArray()); }
public override IEnumerable <object> GetParameters() { var parameters = new List <object>(); parameters.AddRange(_condition.GetParameters()); parameters.AddRange(new[] { _trueValue, _falseValue }); return(parameters); }
private static void ApplySqlInstruction(IDbCommand command, ISqlInstruction sql, ISqlDialect dialect) { var sqlStr = sql.ToString(dialect); var parameters = sql.GetParameters(); command.Parameters.Clear(); var sqlParts = sqlStr.Split('?'); var sqlBuilder = new StringBuilder(); for (var i = 0; i < sqlParts.Length - 1; i++) { var name = "p" + i; command.AddParameter(name, parameters[i]); sqlBuilder.AppendFormat("{0}@{1}", sqlParts[i], name); } sqlBuilder.Append(sqlParts[sqlParts.Length - 1]); command.CommandText = sqlBuilder.ToString(); }
public override IEnumerable <object> GetParameters() { return(ins != null?ins.GetParameters() : (parameters ?? new object[0])); }
public override object[] GetParameters() { return(column2.GetParameters()); }
public override IEnumerable <object> GetParameters() { return(column2.GetParameters()); }
public override object[] GetParameters() { return(ins != null?ins.GetParameters() : (parameters ?? new object[0])); }
public override IEnumerable <object> GetParameters() { return(_exp.GetParameters()); }
public override object[] GetParameters() { return(_exp.GetParameters()); }