protected override Expression VisitSelect(DbSelectExpression select) { this.Write("SELECT "); if (select.IsDistinct) { this.Write("DISTINCT "); } if (select.Take != null) { this.WriteTopClause(select.Take); } this.WriteColumns(select.Columns); if (select.From != null) { this.WriteLine(Indentation.Same); this.Write("FROM "); this.VisitSource(select.From); } if (select.Where != null) { this.WriteLine(Indentation.Same); this.Write("WHERE "); this.VisitPredicate(select.Where); } if (select.GroupBy != null && select.GroupBy.Count > 0) { this.WriteLine(Indentation.Same); this.Write("GROUP BY "); for (int i = 0, n = select.GroupBy.Count; i < n; i++) { if (i > 0) { this.Write(", "); } this.VisitValue(select.GroupBy[i]); } } if (select.OrderBy != null && select.OrderBy.Count > 0) { this.WriteLine(Indentation.Same); this.Write("ORDER BY "); for (int i = 0, n = select.OrderBy.Count; i < n; i++) { DbOrderExpression exp = select.OrderBy[i]; if (i > 0) { this.Write(", "); } this.VisitValue(exp.Expression); if (exp.OrderType != DbOrderType.Ascending) { this.Write(" DESC"); } } } return(select); }
protected override Expression VisitSelect(DbSelectExpression select) { if (select.Skip != null) { throw new InvalidOperationException("SQLCE can only support Skip when it is immediately followed by Take"); } return(base.VisitSelect(select)); }
protected override Expression VisitSelect(DbSelectExpression select) { if (select.Skip != null) { if (select.OrderBy == null && select.OrderBy.Count == 0) { throw new NotSupportedException("Access cannot support the 'skip' operation without explicit ordering"); } else if (select.Take == null) { throw new NotSupportedException("Access cannot support the 'skip' operation without the 'take' operation"); } else { throw new NotSupportedException("Access cannot support the 'skip' operation in this query"); } } return(base.VisitSelect(select)); }
protected override Expression VisitSource(Expression source) { bool saveIsNested = this.isNested; this.isNested = true; switch ((DbExpressionType)source.NodeType) { case DbExpressionType.Table: DbTableExpression table = (DbTableExpression)source; this.WriteTableName(table.Name); if (!this.HideTableAliases) { this.Write(" AS "); this.WriteAliasName(GetAliasName(table.Alias)); } break; case DbExpressionType.Select: DbSelectExpression select = (DbSelectExpression)source; this.Write("("); this.WriteLine(Indentation.Inner); this.Visit(select); this.WriteLine(Indentation.Same); this.Write(")"); this.Write(" AS "); this.WriteAliasName(GetAliasName(select.Alias)); this.Indent(Indentation.Outer); break; case DbExpressionType.Join: this.VisitJoin((DbJoinExpression)source); break; default: throw new InvalidOperationException("Select source is not valid type"); } this.isNested = saveIsNested; return(source); }
public override ISqlPart Visit(DbSelectExpression dbExpression) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="DbExistsExpression"/> class. /// </summary> /// <param name="subSelectExpression">The <see cref="DbSelectExpression"/> that is used as the sub query.</param> internal DbExistsExpression(DbSelectExpression subSelectExpression) { SubSelectExpression = subSelectExpression; }