protected void AppendWhereClause( StringBuilder statement, IComparedColumnsSpecification comparedColumns, IDbCommand command) { statement.Append(" WHERE "); comparedColumns.AddParameters(command, SqlDialect); comparedColumns.AppendComparisons(statement, command, SqlDialect); }
public override IDbCommand Create(IRdbmsProviderCommandExecutionContext commandExecutionContext) { ArgumentUtility.CheckNotNull("commandExecutionContext", commandExecutionContext); var command = commandExecutionContext.CreateDbCommand(); var fullProjection = _orderedColumns.UnionWithSelectedColumns(_selectedColumns); var statement = new StringBuilder(); bool first = true; _comparedColumns.AddParameters(command, SqlDialect); foreach (var table in _unionViewDefinition.GetAllTables()) { if (!first) { statement.Append(" UNION ALL "); } var adjustedProjection = fullProjection.AdjustForTable(table); AppendSelectClause(statement, adjustedProjection); AppendFromClause(statement, table); statement.Append(" WHERE "); _comparedColumns.AppendComparisons(statement, command, SqlDialect); first = false; } AppendOrderByClause(statement, _orderedColumns); statement.Append(SqlDialect.StatementDelimiter); command.CommandText = statement.ToString(); return(command); }