internal override SqlExpression VisitAliasRef(SqlAliasRef aref) { SqlNode node = aref.Alias.Node; if ((node is SqlTable) || (node is SqlTableValuedFunctionCall)) { return(aref); } SqlUnion union = node as SqlUnion; if (union != null) { return(this.ExpandUnion(union)); } SqlSelect select = node as SqlSelect; if (select != null) { return(this.VisitExpression(select.Selection)); } SqlExpression exp = node as SqlExpression; if (exp == null) { throw Error.CouldNotHandleAliasRef(node.NodeType); } return(this.VisitExpression(exp)); }
private static IProviderType GetSqlType(SqlNode node) { SqlExpression expression = node as SqlExpression; if (expression != null) { return(expression.SqlType); } SqlSelect select = node as SqlSelect; if (select != null) { return(select.Selection.SqlType); } SqlTable table = node as SqlTable; if (table != null) { return(table.SqlRowType); } SqlUnion union = node as SqlUnion; if (union == null) { throw Error.UnexpectedNode(node.NodeType); } return(union.GetSqlType()); }
internal override SqlNode VisitUnion(SqlUnion su) { bool changed = false; bool containsLongExpressions = false; SqlSelect left = su.Left as SqlSelect; if (left != null) { this.ConvertColumnsToMax(left, out changed, out containsLongExpressions); } bool flag3 = false; bool flag4 = false; SqlSelect right = su.Right as SqlSelect; if (right != null) { this.ConvertColumnsToMax(right, out flag3, out flag4); } if (!su.All && (containsLongExpressions || flag4)) { this.annotations.Add(su, new SqlServerCompatibilityAnnotation( Strings.TextNTextAndImageCannotOccurInUnion(su.SourceExpression), new SqlProvider.ProviderMode[] { SqlProvider.ProviderMode.Sql2000, SqlProvider.ProviderMode.SqlCE })); } return(base.VisitUnion(su)); }
private void GatherUnionExpressions(SqlNode node, IList <SqlExpression> exprs) { SqlUnion union = node as SqlUnion; if (union != null) { this.GatherUnionExpressions(union.Left, exprs); this.GatherUnionExpressions(union.Right, exprs); } else { SqlSelect select = node as SqlSelect; if (select != null) { SqlAliasRef selection = select.Selection as SqlAliasRef; if (selection != null) { this.GatherUnionExpressions(selection.Alias.Node, exprs); } else { exprs.Add(select.Selection); } } } }
private SqlExpression ExpandUnion(SqlUnion union) { IList <SqlExpression> exprs = new List <SqlExpression>(2); this.GatherUnionExpressions(union, exprs); this.sourceExpression = union.SourceExpression; return(this.ExpandTogether(exprs)); }
internal override SqlSelect VisitSelect(SqlSelect select) { base.VisitSelect(select); SqlUnion union = this.GetUnion(select.From); if (union != null) { SqlSelect left = union.Left as SqlSelect; SqlSelect right = union.Right as SqlSelect; if (!((left != null) & (right != null))) { return(select); } int num = 0; int count = left.Row.Columns.Count; while (num < count) { left.Row.Columns[num].Ordinal = select.Row.Columns.Count + num; num++; } int num3 = 0; int num4 = right.Row.Columns.Count; while (num3 < num4) { right.Row.Columns[num3].Ordinal = select.Row.Columns.Count + num3; num3++; } int num5 = 0; int num6 = select.Row.Columns.Count; while (num5 < num6) { SqlExprSet expression = select.Row.Columns[num5].Expression as SqlExprSet; if (expression != null) { int num7 = 0; int num8 = expression.Expressions.Count; while (num7 < num8) { SqlColumnRef ref2 = expression.Expressions[num7] as SqlColumnRef; if ((ref2 != null) && (num7 >= select.Row.Columns.Count)) { ref2.Column.Ordinal = num5; } num7++; } } num5++; } Comparison <SqlColumn> comparison = delegate(SqlColumn x, SqlColumn y) { return(x.Ordinal - y.Ordinal); }; left.Row.Columns.Sort(comparison); right.Row.Columns.Sort(comparison); } return(select); }
internal override SqlNode VisitUnion(SqlUnion su) { this.orders = null; su.Left = this.Visit(su.Left); this.orders = null; su.Right = this.Visit(su.Right); this.orders = null; return(su); }
internal override SqlNode VisitUnion(SqlUnion su) { bool forceReferenceAll = this.forceReferenceAll; this.forceReferenceAll = true; su.Left = this.Visit(su.Left); su.Right = this.Visit(su.Right); this.forceReferenceAll = forceReferenceAll; return(su); }
internal override SqlNode VisitUnion(SqlUnion su) { if (su.All) { this.IsValid = false; } this.IsDistinct = true; this.AddIdentityMembers(su.GetClrType().GetProperties()); return(su); }
internal override SqlNode VisitUnion(SqlUnion su) { Scope current = this.current; this.current = null; SqlNode node = base.VisitUnion(su); this.current = current; return(node); }
// Methods private SqlUnion GetUnion(SqlSource source) { SqlAlias alias = source as SqlAlias; if (alias != null) { SqlUnion node = alias.Node as SqlUnion; if (node != null) { return(node); } } return(null); }
private static Type GetClrType(SqlNode node) { SqlTableValuedFunctionCall call = node as SqlTableValuedFunctionCall; if (call != null) { return(call.RowType.Type); } SqlExpression expression = node as SqlExpression; if (expression != null) { if (TypeSystem.IsSequenceType(expression.ClrType)) { return(TypeSystem.GetElementType(expression.ClrType)); } return(expression.ClrType); } SqlSelect select = node as SqlSelect; if (select != null) { return(select.Selection.ClrType); } SqlTable table = node as SqlTable; if (table != null) { return(table.RowType.Type); } SqlUnion union = node as SqlUnion; if (union == null) { throw Error.UnexpectedNode(node.NodeType); } return(union.GetClrType()); }
internal override SqlNode VisitUnion(SqlUnion su) { this.canJoin = false; return(base.VisitUnion(su)); }
internal virtual SqlNode VisitUnion(SqlUnion su) { su.Left = this.Visit(su.Left); su.Right = this.Visit(su.Right); return(su); }
internal override SqlNode VisitUnion(SqlUnion su) { return(su); }
internal override SqlNode VisitUnion(SqlUnion su) { return(new SqlUnion(this.Visit(su.Left), this.Visit(su.Right), su.All)); }