private void Build(StringBuilder sb, List <object> args, Sql lhs) { if (!String.IsNullOrEmpty(_sql)) { // Add SQL to the string if (sb.Length > 0) { sb.Append("\n"); } var sql = Database.ProcessParams(_sql, _args, args); if (Is(lhs, "WHERE ") && Is(this, "WHERE ")) { sql = "AND " + sql.Substring(6); } if (Is(lhs, "ORDER BY ") && Is(this, "ORDER BY ")) { sql = ", " + sql.Substring(9); } sb.Append(sql); } // Now do rhs if (_rhs != null) { _rhs.Build(sb, args, this); } }
public string ResolveClauses(List <object> finalParams) { foreach (var item in this) { item.Sql = Database.ProcessParams(item.Sql, item.Parameters.ToArray(), finalParams); } return(prefix + string.Join(joiner, this.Select(c => c.Sql).ToArray()) + postfix); }
public Template(SqlBuilder builder, string sql, params object[] parameters) { this.sql = Database.ProcessParams(sql, parameters, finalParams); this.builder = builder; }