protected override SqlSelect VisitSqlSelect(SqlSelect sqlSelect) { _sql.Append("SELECT "); if (sqlSelect.IsCounting) { _sql.Append("COUNT(0)"); } else { if (sqlSelect.IsDistinct) { _sql.Append("DISTINCT "); } else if (sqlSelect.Top.HasValue) { _sql.Append("TOP "); _sql.Append(sqlSelect.Top.Value); _sql.Append(" "); } //éĉİçċ if (sqlSelect.Selection == null) { _sql.Append("*"); } else { this.Visit(sqlSelect.Selection); } } //FROM _sql.AppendLine(); _sql.Append("FROM "); this.Visit(sqlSelect.From); //WHERE if (sqlSelect.Where != null) { _sql.AppendLine(); _sql.Append("WHERE "); this.Visit(sqlSelect.Where); } //ORDER BY if (!sqlSelect.IsCounting && sqlSelect.OrderBy != null && sqlSelect.OrderBy.Count > 0) { _sql.AppendLine(); _sql.Append("ORDER BY "); for (int i = 0, c = sqlSelect.OrderBy.Count; i < c; i++) { if (i > 0) { _sql.Append(", "); } this.Visit(sqlSelect.OrderBy[i] as SqlOrderBy); } } return(sqlSelect); }
protected override SqlSelect VisitSqlSelect(SqlSelect sqlSelect) { _sql.Append("SELECT "); //SELECT this.GenerateSelection(sqlSelect); //FROM _sql.AppendLine(); _sql.Append("FROM "); this.Visit(sqlSelect.From); //WHERE if (sqlSelect.Where != null) { _sql.AppendLine(); _sql.Append("WHERE "); this.Visit(sqlSelect.Where); } //ORDER BY if (!sqlSelect.IsCounting && sqlSelect.OrderBy != null && sqlSelect.OrderBy.Count > 0) { _sql.AppendLine(); this.Visit(sqlSelect.OrderBy); } return(sqlSelect); }