Exemplo n.º 1
0
        public QsiExpressionNode VisitEventDeclarationCompareFunctionParameter(EventDeclarationCompareFunctionParameter eventDeclarationCompareFunctionParameter)
        {
            return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
            {
                n.Member.SetValue(TreeHelper.CreateFunction(SqlServerKnownFunction.EventDeclarationCompare));

                if (eventDeclarationCompareFunctionParameter.Name != null)
                {
                    n.Parameters.Add(TreeHelper.Create <QsiTableExpressionNode>(tn =>
                    {
                        tn.Table.SetValue(new QsiTableReferenceNode
                        {
                            Identifier = IdentifierVisitor.CreateQualifiedIdentifier(eventDeclarationCompareFunctionParameter.Name.MultiPartIdentifier)
                        });
                    }));
                }

                if (eventDeclarationCompareFunctionParameter.EventValue != null)
                {
                    n.Parameters.Add(VisitScalarExpression(eventDeclarationCompareFunctionParameter.EventValue));
                }

                if (eventDeclarationCompareFunctionParameter.SourceDeclaration != null)
                {
                    n.Parameters.Add(VisitSourceDeclaration(eventDeclarationCompareFunctionParameter.SourceDeclaration));
                }

                SqlServerTree.PutFragmentSpan(n, eventDeclarationCompareFunctionParameter);
            }));
        }
Exemplo n.º 2
0
        public QsiTableNode VisitSelectStatement(SelectStatement selectStatement)
        {
            var tableNode = VisitQueryExpression(selectStatement.QueryExpression);

            if (selectStatement.WithCtesAndXmlNamespaces != null)
            {
                var tableDirectivesNode = VisitWithCtesAndXmlNamespaces(selectStatement.WithCtesAndXmlNamespaces);

                switch (tableNode)
                {
                case QsiDerivedTableNode derivedTableNode:
                    derivedTableNode.Directives.SetValue(tableDirectivesNode);
                    break;

                default:
                    return(TreeHelper.Create <QsiDerivedTableNode>(n =>
                    {
                        n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
                        n.Source.SetValue(tableNode);
                        n.Directives.SetValue(tableDirectivesNode);

                        SqlServerTree.PutFragmentSpan(n, selectStatement);
                    }));
                }
            }

            SqlServerTree.PutFragmentSpan(tableNode, selectStatement);

            return(tableNode);
        }
Exemplo n.º 3
0
        public QsiTableNode VisitFromClause(FromClause fromClause)
        {
            IList <TableReference> tableReferences = fromClause.TableReferences;

            if (tableReferences.Count == 1)
            {
                return(VisitTableReference(tableReferences.FirstOrDefault()));
            }

            var joinedTableNode = TreeHelper.Create <QsiJoinedTableNode>(n =>
            {
                n.Left.SetValue(VisitTableReference(tableReferences[0]));
                n.Right.SetValue(VisitTableReference(tableReferences[1]));
                n.IsComma = true;
            });

            foreach (var tableExpression in tableReferences.Skip(2))
            {
                var node = joinedTableNode;

                joinedTableNode = TreeHelper.Create <QsiJoinedTableNode>(n =>
                {
                    n.Left.SetValue(node);
                    n.Right.SetValue(VisitTableReference(tableExpression));
                    n.IsComma = true;
                });
            }

            SqlServerTree.PutFragmentSpan(joinedTableNode, fromClause);

            return(joinedTableNode);
        }
Exemplo n.º 4
0
        public QsiExpressionNode VisitInPredicate(InPredicate inPredicate)
        {
            QsiExpressionNode node = TreeHelper.Create <QsiBinaryExpressionNode>(n =>
            {
                n.Operator = "IN";
                n.Left.SetValue(VisitScalarExpression(inPredicate.Expression));

                if (inPredicate.Subquery != null)
                {
                    n.Right.SetValue(VisitScalarSubquery(inPredicate.Subquery));
                }
                else
                {
                    n.Right.SetValue(TreeHelper.Create <QsiMultipleExpressionNode>(mn =>
                    {
                        mn.Elements.AddRange(inPredicate.Values.Select(VisitScalarExpression));
                    }));
                }
            });

            if (inPredicate.NotDefined)
            {
                node = TreeHelper.CreateUnary(SqlServerKnownOperator.Not, node);
            }

            SqlServerTree.PutFragmentSpan(node, inPredicate);

            return(node);
        }
Exemplo n.º 5
0
        public QsiExpressionNode VisitSubqueryComparisonPredicate(SubqueryComparisonPredicate subqueryComparisonPredicate)
        {
            var expressionNode = TreeHelper.Create <QsiBinaryExpressionNode>(ln =>
            {
                ln.Left.SetValue(VisitScalarExpression(subqueryComparisonPredicate.Expression));
                ln.Right.SetValue(VisitScalarSubquery(subqueryComparisonPredicate.Subquery));

                ln.Operator = ConvertBooleanComparisonType(subqueryComparisonPredicate.ComparisonType);
            });

            if (subqueryComparisonPredicate.SubqueryComparisonPredicateType == SubqueryComparisonPredicateType.None)
            {
                SqlServerTree.PutFragmentSpan(expressionNode, subqueryComparisonPredicate);
                return(expressionNode);
            }

            return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
            {
                n.Member.SetValue(TreeHelper.CreateFunction(subqueryComparisonPredicate.SubqueryComparisonPredicateType switch
                {
                    SubqueryComparisonPredicateType.All => SqlServerKnownFunction.All,
                    SubqueryComparisonPredicateType.Any => SqlServerKnownFunction.Any,
                    _ => throw new InvalidOperationException()
                }));

                n.Parameters.Add(expressionNode);
                SqlServerTree.PutFragmentSpan(n, subqueryComparisonPredicate);
            }));
Exemplo n.º 6
0
        public QsiDerivedColumnNode VisitSelectSetVariable(SelectSetVariable selectSetVariable)
        {
            return(TreeHelper.Create <QsiDerivedColumnNode>(n =>
            {
                var kind = selectSetVariable.AssignmentKind switch
                {
                    AssignmentKind.Equals => QsiAssignmentKind.Equals,
                    AssignmentKind.AddEquals => QsiAssignmentKind.AddEquals,
                    AssignmentKind.DivideEquals => QsiAssignmentKind.DivideEquals,
                    AssignmentKind.ModEquals => QsiAssignmentKind.ModEquals,
                    AssignmentKind.MultiplyEquals => QsiAssignmentKind.MultiplyEquals,
                    AssignmentKind.SubtractEquals => QsiAssignmentKind.SubtractEquals,
                    AssignmentKind.BitwiseAndEquals => QsiAssignmentKind.BitwiseAndEquals,
                    AssignmentKind.BitwiseOrEquals => QsiAssignmentKind.BitwiseOrEquals,
                    AssignmentKind.BitwiseXorEquals => QsiAssignmentKind.BitwiseXorEquals,
                    _ => throw new InvalidOperationException()
                };

                n.Expression.SetValue(TreeHelper.Create <QsiSetVariableExpressionNode>(en =>
                {
                    en.Target = IdentifierVisitor.VisitVariableReference(selectSetVariable.Variable);
                    en.AssignmentKind = kind;
                    en.Value.SetValue(ExpressionVisitor.VisitScalarExpression(selectSetVariable.Expression));
                }));

                SqlServerTree.PutFragmentSpan(n, selectSetVariable);
            }));
        }
Exemplo n.º 7
0
        public IQsiDefinitionNode VisitViewStatementBody(ViewStatementBody viewStatementBody)
        {
            if (viewStatementBody is not(CreateViewStatement or CreateOrAlterViewStatement))
            {
                throw TreeHelper.NotSupportedTree(viewStatementBody);
            }

            var node = new SqlServerViewDefinitionNode
            {
                IsAlter         = viewStatementBody is CreateOrAlterViewStatement,
                IsMaterialiazed = viewStatementBody.IsMaterialized,
                WithCheckOption = viewStatementBody.WithCheckOption,
                ViewOptions     = viewStatementBody.ViewOptions?.Select(option => option.OptionKind.ToString()).ToArray(),
                Identifier      = IdentifierVisitor.CreateQualifiedIdentifier(viewStatementBody.SchemaObjectName)
            };

            if (ListUtility.IsNullOrEmpty(viewStatementBody.Columns))
            {
                node.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
            }
            else
            {
                var columnsDeclaration = new QsiColumnsDeclarationNode();
                columnsDeclaration.Columns.AddRange(TableVisitor.CreateSequentialColumnNodes(viewStatementBody.Columns));
                node.Columns.SetValue(columnsDeclaration);
            }

            node.Source.SetValue(TableVisitor.VisitSelectStatement(viewStatementBody.SelectStatement));

            SqlServerTree.PutFragmentSpan(node, viewStatementBody);

            return(node);
        }
Exemplo n.º 8
0
        public QsiDerivedTableNode VisitCommonTableExpression(CommonTableExpression commonTableExpression)
        {
            return(TreeHelper.Create <QsiDerivedTableNode>(n =>
            {
                n.Source.SetValue(VisitQueryExpression(commonTableExpression.QueryExpression));

                var columnsDeclaration = new QsiColumnsDeclarationNode();

                if (commonTableExpression.Columns == null || commonTableExpression.Columns.Count == 0)
                {
                    columnsDeclaration.Columns.Add(new QsiAllColumnNode());
                }
                else
                {
                    columnsDeclaration.Columns.AddRange(CreateSequentialColumnNodes(commonTableExpression.Columns));
                }

                n.Columns.SetValue(columnsDeclaration);

                if (commonTableExpression.ExpressionName != null)
                {
                    n.Alias.SetValue(CreateAliasNode(commonTableExpression.ExpressionName));
                }

                SqlServerTree.PutFragmentSpan(n, commonTableExpression);
            }));
        }
Exemplo n.º 9
0
        public SqlServerAlterUserActionNode VisitAlterUser(AlterUserStatement alterUserStatement)
        {
            var node = new SqlServerAlterUserActionNode
            {
                TargetUser = IdentifierVisitor.CreateIdentifier(alterUserStatement.Name)
            };

            foreach (var userOption in alterUserStatement.UserOptions)
            {
                if (userOption is IdentifierPrincipalOption identifierPrincipalOption)
                {
                    switch (userOption.OptionKind)
                    {
                    case PrincipalOptionKind.Name:
                        node.NewUserName = IdentifierVisitor.CreateIdentifier(identifierPrincipalOption.Identifier);
                        break;

                    case PrincipalOptionKind.DefaultSchema:
                        node.DefaultSchema = IdentifierVisitor.CreateIdentifier(identifierPrincipalOption.Identifier);
                        break;
                    }
                }
            }

            SqlServerTree.PutFragmentSpan(node, alterUserStatement);

            return(node);
        }
Exemplo n.º 10
0
        public QsiExpressionNode VisitGroupSpecifcation(GroupingSpecification groupingSpecification)
        {
            switch (groupingSpecification)
            {
            case CompositeGroupingSpecification compositeGroupingSpecification:
                return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
                {
                    n.Member.SetValue(TreeHelper.CreateFunction("COMPOSITE"));
                    n.Parameters.AddRange(compositeGroupingSpecification.Items.Select(VisitGroupSpecifcation));

                    SqlServerTree.PutFragmentSpan(n, compositeGroupingSpecification);
                }));

            // CUBE ( ... )
            case CubeGroupingSpecification cubeGroupingSpecification:
                return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
                {
                    n.Member.SetValue(TreeHelper.CreateFunction("CUBE"));
                    n.Parameters.AddRange(cubeGroupingSpecification.Arguments.Select(VisitGroupSpecifcation));

                    SqlServerTree.PutFragmentSpan(n, cubeGroupingSpecification);
                }));

            case ExpressionGroupingSpecification expressionGroupingSpecification:
                return(ExpressionVisitor.VisitScalarExpression(expressionGroupingSpecification.Expression));

            // ROLLUP ( ... )
            case RollupGroupingSpecification rollupGroupingSpecification:
                return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
                {
                    n.Member.SetValue(TreeHelper.CreateFunction("ROLLUP"));
                    n.Parameters.AddRange(rollupGroupingSpecification.Arguments.Select(VisitGroupSpecifcation));

                    SqlServerTree.PutFragmentSpan(n, rollupGroupingSpecification);
                }));

            // ()
            case GrandTotalGroupingSpecification grandTotalGroupingSpecification:
                return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
                {
                    n.Member.SetValue(TreeHelper.CreateFunction("GRAND_TOTAL"));
                    SqlServerTree.PutFragmentSpan(n, grandTotalGroupingSpecification);
                }));

            // GROUPING SETS ( ... )
            case GroupingSetsGroupingSpecification groupingSetsGroupingSpecification:
                return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
                {
                    n.Member.SetValue(TreeHelper.CreateFunction("GROUPING_SETS"));
                    n.Parameters.AddRange(groupingSetsGroupingSpecification.Sets.Select(VisitGroupSpecifcation));

                    SqlServerTree.PutFragmentSpan(n, groupingSetsGroupingSpecification);
                }));

            default:
                throw TreeHelper.NotSupportedTree(groupingSpecification);
            }
        }
Exemplo n.º 11
0
        public QsiWhereExpressionNode VisitWhereClause(WhereClause whereClause)
        {
            return(TreeHelper.Create <QsiWhereExpressionNode>(n =>
            {
                n.Expression.SetValue(ExpressionVisitor.VisitBooleanExpression(whereClause.SearchCondition));

                SqlServerTree.PutFragmentSpan(n, whereClause);
            }));
        }
Exemplo n.º 12
0
        public QsiMultipleOrderExpressionNode VisitOrderByClause(OrderByClause orderByClause)
        {
            var node = new QsiMultipleOrderExpressionNode();

            node.Orders.AddRange(orderByClause.OrderByElements.Select(VisitExpressionWithSortOrder));
            SqlServerTree.PutFragmentSpan(node, orderByClause);

            return(node);
        }
Exemplo n.º 13
0
        public QsiDerivedTableNode VisitOdbcQualifiedJoinTableReference(OdbcQualifiedJoinTableReference odbcQualifiedJoinTableReference)
        {
            return(TreeHelper.Create <QsiDerivedTableNode>(n =>
            {
                n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
                n.Source.SetValue(VisitTableReference(odbcQualifiedJoinTableReference.TableReference));

                SqlServerTree.PutFragmentSpan(n, odbcQualifiedJoinTableReference);
            }));
        }
Exemplo n.º 14
0
        public QsiTableNode VisitJoinParenthesisTableReference(JoinParenthesisTableReference joinParenthesisTableReference)
        {
            return(TreeHelper.Create <QsiDerivedTableNode>(n =>
            {
                n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
                n.Source.SetValue(VisitTableReference(joinParenthesisTableReference.Join));

                SqlServerTree.PutFragmentSpan(n, joinParenthesisTableReference);
            }));
        }
Exemplo n.º 15
0
        public QsiOrderExpressionNode VisitExpressionWithSortOrder(ExpressionWithSortOrder expressionWithSortOrder)
        {
            return(TreeHelper.Create <QsiOrderExpressionNode>(n =>
            {
                n.Expression.SetValue(ExpressionVisitor.VisitScalarExpression(expressionWithSortOrder.Expression));
                n.Order = expressionWithSortOrder.SortOrder == SortOrder.Descending ? QsiSortOrder.Descending : QsiSortOrder.Ascending;

                SqlServerTree.PutFragmentSpan(n, expressionWithSortOrder);
            }));
        }
Exemplo n.º 16
0
        public QsiTableDirectivesNode VisitWithCtesAndXmlNamespaces(WithCtesAndXmlNamespaces selectStatementWithCtesAndXmlNamespaces)
        {
            return(TreeHelper.Create <QsiTableDirectivesNode>(n =>
            {
                n.IsRecursive = true;
                n.Tables.AddRange(selectStatementWithCtesAndXmlNamespaces.CommonTableExpressions.Select(VisitCommonTableExpression));

                SqlServerTree.PutFragmentSpan(n, selectStatementWithCtesAndXmlNamespaces);
            }));
        }
Exemplo n.º 17
0
        public QsiUnaryExpressionNode VisitBooleanNotExpression(BooleanNotExpression booleanNotExpression)
        {
            return(TreeHelper.Create <QsiUnaryExpressionNode>(n =>
            {
                n.Operator = SqlServerKnownOperator.Not;
                n.Expression.SetValue(VisitBooleanExpression(booleanNotExpression.Expression));

                SqlServerTree.PutFragmentSpan(n, booleanNotExpression);
            }));
        }
Exemplo n.º 18
0
        public QsiInvokeExpressionNode VisitExistsPredicate(ExistsPredicate existsPredicate)
        {
            return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
            {
                n.Member.SetValue(TreeHelper.CreateFunction(SqlServerKnownFunction.Exists));
                n.Parameters.Add(VisitScalarSubquery(existsPredicate.Subquery));

                SqlServerTree.PutFragmentSpan(n, existsPredicate);
            }));
        }
Exemplo n.º 19
0
        public QsiColumnNode VisitSelectScalarExpression(SelectScalarExpression selectScalarExpression)
        {
            QsiExpressionNode      expression = null;
            QsiColumnReferenceNode column     = null;

            if (selectScalarExpression.Expression is ColumnReferenceExpression columnReferenceExpression)
            {
                column = new QsiColumnReferenceNode
                {
                    Name = IdentifierVisitor.CreateQualifiedIdentifier(columnReferenceExpression.MultiPartIdentifier)
                };

                if (selectScalarExpression.ColumnName == null)
                {
                    SqlServerTree.PutFragmentSpan(column, selectScalarExpression);
                    return(column);
                }
            }
            else
            {
                expression = ExpressionVisitor.VisitScalarExpression(selectScalarExpression.Expression);
            }

            return(TreeHelper.Create <QsiDerivedColumnNode>(n =>
            {
                if (column != null)
                {
                    n.Column.SetValue(column);
                }
                else if (expression != null)
                {
                    n.Expression.SetValue(expression);
                }

                var columnName = selectScalarExpression.ColumnName;

                if (columnName != null)
                {
                    if (columnName.Identifier == null)
                    {
                        n.Alias.SetValue(new QsiAliasNode
                        {
                            Name = new QsiIdentifier(columnName.Value, false)
                        });
                    }
                    else
                    {
                        n.Alias.SetValue(CreateAliasNode(columnName.Identifier));
                    }
                }

                SqlServerTree.PutFragmentSpan(n, selectScalarExpression);
            }));
        }
Exemplo n.º 20
0
        public QsiDerivedTableNode VisitQueryParenthesisExpression(QueryParenthesisExpression queryParenthesisExpression)
        {
            return(TreeHelper.Create <QsiDerivedTableNode>(n =>
            {
                // Ignored ForClause, OffsetClause, OrderByClause
                n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
                n.Source.SetValue(VisitQueryExpression(queryParenthesisExpression.QueryExpression));

                SqlServerTree.PutFragmentSpan(n, queryParenthesisExpression);
            }));
        }
Exemplo n.º 21
0
        public QsiColumnNode VisitSelectStarExpression(SelectStarExpression selectStarExpression)
        {
            return(TreeHelper.Create <QsiAllColumnNode>(n =>
            {
                if (selectStarExpression.Qualifier != null)
                {
                    n.Path = IdentifierVisitor.CreateQualifiedIdentifier(selectStarExpression.Qualifier);
                }

                SqlServerTree.PutFragmentSpan(n, selectStarExpression);
            }));
        }
Exemplo n.º 22
0
        public QsiBinaryExpressionNode VisitBooleanIsNullExpression(BooleanIsNullExpression booleanIsNullExpression)
        {
            return(TreeHelper.Create <QsiBinaryExpressionNode>(n =>
            {
                n.Left.SetValue(VisitScalarExpression(booleanIsNullExpression.Expression));
                n.Right.SetValue(TreeHelper.CreateNullLiteral());

                n.Operator = booleanIsNullExpression.IsNot ? SqlServerKnownOperator.NotEqualToExclamation : SqlServerKnownOperator.Equals;

                SqlServerTree.PutFragmentSpan(n, booleanIsNullExpression);
            }));
        }
Exemplo n.º 23
0
        public QsiBinaryExpressionNode VisitBooleanComparisonExpression(BooleanComparisonExpression booleanComparisonExpression)
        {
            return(TreeHelper.Create <QsiBinaryExpressionNode>(n =>
            {
                n.Left.SetValue(VisitScalarExpression(booleanComparisonExpression.FirstExpression));
                n.Right.SetValue(VisitScalarExpression(booleanComparisonExpression.SecondExpression));

                n.Operator = ConvertBooleanComparisonType(booleanComparisonExpression.ComparisonType);

                SqlServerTree.PutFragmentSpan(n, booleanComparisonExpression);
            }));
        }
Exemplo n.º 24
0
        public QsiChangeSearchPathActionNode VisitUseStatement(UseStatement useStatement)
        {
            var node = new QsiChangeSearchPathActionNode
            {
                Identifiers = new[]
                {
                    IdentifierVisitor.CreateIdentifier(useStatement.DatabaseName),
                }
            };

            SqlServerTree.PutFragmentSpan(node, useStatement);

            return(node);
        }
Exemplo n.º 25
0
        public QsiGroupingExpressionNode VisitGroupByClause(GroupByClause groupByClause, HavingClause havingClause)
        {
            return(TreeHelper.Create <QsiGroupingExpressionNode>(n =>
            {
                n.Items.AddRange(groupByClause.GroupingSpecifications.Select(VisitGroupSpecifcation));

                if (havingClause != null)
                {
                    n.Having.SetValue(VisitHavingClause(havingClause));
                }

                SqlServerTree.PutFragmentSpan(n, groupByClause);
            }));
        }
Exemplo n.º 26
0
        public QsiDerivedTableNode VisitQueryDerivedTable(QueryDerivedTable queryDerivedTable)
        {
            return(TreeHelper.Create <QsiDerivedTableNode>(n =>
            {
                if (queryDerivedTable.Alias != null)
                {
                    n.Alias.SetValue(CreateAliasNode(queryDerivedTable.Alias));
                }

                n.Columns.SetValue(TreeHelper.CreateAllColumnsDeclaration());
                n.Source.SetValue(VisitQueryExpression(queryDerivedTable.QueryExpression));

                SqlServerTree.PutFragmentSpan(n, queryDerivedTable);
            }));
        }
Exemplo n.º 27
0
        public QsiExpressionNode VisitFullTextPredicate(FullTextPredicate fullTextPredicate)
        {
            return(TreeHelper.Create <QsiInvokeExpressionNode>(n =>
            {
                n.Member.SetValue(TreeHelper.CreateFunction(SqlServerKnownFunction.FullText));
                n.Parameters.AddRange(fullTextPredicate.Columns.Select(ExpressionVisitor.VisitColumnReferenceExpression));

                n.Parameters.Add(fullTextPredicate.Value != null ?
                                 VisitValueExpression(fullTextPredicate.Value) :
                                 VisitLiteral(fullTextPredicate.PropertyName));

                n.Parameters.Add(VisitValueExpression(fullTextPredicate.LanguageTerm));

                SqlServerTree.PutFragmentSpan(n, fullTextPredicate);
            }));
        }
Exemplo n.º 28
0
        public SqlServerJoinedTableNode CreateJoinedTableNode(string joinType, JoinTableReference joinTableReference, BooleanExpression searchCondition = null)
        {
            return(TreeHelper.Create <SqlServerJoinedTableNode>(n =>
            {
                n.Left.SetValue(VisitTableReference(joinTableReference.FirstTableReference));
                n.Right.SetValue(VisitTableReference(joinTableReference.SecondTableReference));

                if (searchCondition != null)
                {
                    n.Expression.SetValue(ExpressionVisitor.VisitBooleanExpression(searchCondition));
                }

                n.JoinType = joinType;

                SqlServerTree.PutFragmentSpan(n, joinTableReference);
            }));
        }
Exemplo n.º 29
0
        public QsiBinaryExpressionNode VisitBooleanBinaryExpression(BooleanBinaryExpression booleanBinaryExpression)
        {
            return(TreeHelper.Create <QsiBinaryExpressionNode>(n =>
            {
                n.Left.SetValue(VisitBooleanExpression(booleanBinaryExpression.FirstExpression));
                n.Right.SetValue(VisitBooleanExpression(booleanBinaryExpression.SecondExpression));

                n.Operator = booleanBinaryExpression.BinaryExpressionType switch
                {
                    BooleanBinaryExpressionType.And => SqlServerKnownOperator.And,
                    BooleanBinaryExpressionType.Or => SqlServerKnownOperator.Or,
                    _ => throw new InvalidOperationException()
                };

                SqlServerTree.PutFragmentSpan(n, booleanBinaryExpression);
            }));
        }
Exemplo n.º 30
0
        public SqlServerBinaryTableNode VisitBinaryQueryExpression(BinaryQueryExpression binaryQueryExpression)
        {
            return(TreeHelper.Create <SqlServerBinaryTableNode>(n =>
            {
                n.Left.SetValue(VisitQueryExpression(binaryQueryExpression.FirstQueryExpression));
                n.Right.SetValue(VisitQueryExpression(binaryQueryExpression.SecondQueryExpression));

                n.BinaryTableType = binaryQueryExpression.BinaryQueryExpressionType switch
                {
                    BinaryQueryExpressionType.Except => SqlServerBinaryTableType.Except,
                    BinaryQueryExpressionType.Intersect => SqlServerBinaryTableType.Intersect,
                    BinaryQueryExpressionType.Union => SqlServerBinaryTableType.Union,
                    _ => throw new InvalidOperationException()
                };

                SqlServerTree.PutFragmentSpan(n, binaryQueryExpression);
            }));
        }