public override void Visit(BooleanComparisonExpression expression)
 {
     if (expression.IsEqualityComparison())
     {
         Comparisons.Add(expression);
     }
 }
Example #2
0
        public override void VisitBooleanComparisonExpression(BooleanComparisonExpression booleanComparisonExpression)
        {
            var(fieldName, value) = CheckComparisonArguments(booleanComparisonExpression.Left, booleanComparisonExpression.Right);
            switch (booleanComparisonExpression.Type)
            {
            case BooleanComparisonType.Equals:
                Push(new Term()
                {
                    FieldName = fieldName,
                    Value     = GetTerm(value)
                });
                break;

            case BooleanComparisonType.GreaterThan:
                Push(new Range()
                {
                    FieldName   = fieldName,
                    GreaterThan = GetTerm(value)
                });
                break;

            case BooleanComparisonType.GreaterThanOrEqualTo:
                Push(new Range()
                {
                    FieldName        = fieldName,
                    GreaterThanEqual = GetTerm(value)
                });
                break;

            case BooleanComparisonType.LessThan:
                Push(new Range()
                {
                    FieldName = fieldName,
                    LessThan  = GetTerm(value)
                });
                break;

            case BooleanComparisonType.LessThanOrEqualTo:
                Push(new Range()
                {
                    FieldName     = fieldName,
                    LessThanEqual = GetTerm(value)
                });
                break;

            case BooleanComparisonType.NotEqualTo:
                Push(new Bool()
                {
                    MustNot = new List <BoolOperation>()
                    {
                        new Term()
                        {
                            FieldName = fieldName,
                            Value     = GetTerm(value),
                        }
                    }
                });
                break;
            }
        }
Example #3
0
        public void TestCloneBooleanComparisonExpression()
        {
            BooleanComparisonExpression booleanComparisonExpression = new BooleanComparisonExpression()
            {
                Type = BooleanComparisonType.Equals,
                Left = new ColumnReference()
                {
                    Identifiers = new List <string>()
                    {
                        "c1"
                    }
                },
                Right = new IntegerLiteral()
                {
                    Value = 3
                }
            };

            var clone = booleanComparisonExpression.Clone() as BooleanComparisonExpression;

            Assert.AreEqual(booleanComparisonExpression, clone);
            Assert.IsFalse(ReferenceEquals(booleanComparisonExpression, clone));
            Assert.IsFalse(ReferenceEquals(booleanComparisonExpression.Left, clone.Left));
            Assert.IsFalse(ReferenceEquals(booleanComparisonExpression.Right, clone.Right));
        }
        private void BuildEqualsSameLiteral(BooleanExpression search, ScalarExpression firstParam, Literal literal)
        {
            var newExpression = new BooleanParenthesisExpression();
            var expression    = new BooleanBinaryExpression();

            newExpression.Expression = expression;

            expression.BinaryExpressionType = BooleanBinaryExpressionType.Or;
            var isnull = new BooleanIsNullExpression();

            isnull.Expression          = firstParam;
            expression.FirstExpression = isnull;

            var second = new BooleanComparisonExpression();

            second.FirstExpression      = firstParam;
            second.SecondExpression     = literal;
            expression.SecondExpression = second;

            var sql = ScriptDom.GenerateTSql(newExpression);

            _replacementsToMake.Add(new Replacements
            {
                Original         = _script.Substring(search.StartOffset, search.FragmentLength),
                OriginalLength   = search.FragmentLength,
                OriginalOffset   = search.StartOffset,
                Replacement      = sql,
                OriginalFragment = _currentFragment
            });
        }
Example #5
0
 public override void Visit(BooleanComparisonExpression expression)
 {
     if (expression.IsEqualityComparison())
     {
         Comparisons.Add(expression);
     }
 }
Example #6
0
        public void TestBinaryExpressionDivide()
        {
            var actual   = QueryBuilder.BooleanExpression <TestClass>(x => (x.Long / 1) == 0);
            var expected = new BooleanComparisonExpression()
            {
                Type = BooleanComparisonType.Equals,
                Left = new Expressions.BinaryExpression()
                {
                    Left = new ColumnReference()
                    {
                        Identifiers = new List <string>()
                        {
                            "Long"
                        },
                    },
                    Right = new IntegerLiteral()
                    {
                        Value = 1
                    },
                    Type = BinaryType.Divide
                },
                Right = new IntegerLiteral()
                {
                    Value = 0
                }
            };

            actual.Should().BeEquivalentTo(expected, x => x.RespectingRuntimeTypes());
        }
Example #7
0
        public void TestBooleanComparisonExpressionAccept()
        {
            Mock <KoraliumSqlVisitor>   mock = new Mock <KoraliumSqlVisitor>();
            BooleanComparisonExpression booleanComparisonExpression = new BooleanComparisonExpression();

            booleanComparisonExpression.Accept(mock.Object);
            mock.Verify(x => x.VisitBooleanComparisonExpression(booleanComparisonExpression));
        }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            var secondExpression = node.SecondExpression.FirstNoneParenthesisExpression();
            var firstExpression = node.FirstExpression.FirstNoneParenthesisExpression();
            checkHasUnparametrizedWhereClauses(secondExpression, firstExpression);

            base.ExplicitVisit(node);
        }
Example #9
0
 public void Visit(BooleanComparisonExpression booleanComparisonExpression)
 {
     if (_innerVisitor != null)
     {
         booleanComparisonExpression.Accept(_innerVisitor);
     }
     booleanComparisonExpression.Left.Accept(this);
     booleanComparisonExpression.Right.Accept(this);
 }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            var secondExpression = node.SecondExpression.FirstNoneParenthesisExpression();
            var firstExpression  = node.FirstExpression.FirstNoneParenthesisExpression();

            checkHasUnparametrizedWhereClauses(secondExpression, firstExpression);

            base.ExplicitVisit(node);
        }
        private void checkForNullLiterals(BooleanComparisonExpression comparisonExpression)
        {
            if (comparisonExpression == null) return;

            var firstExpression = comparisonExpression.FirstExpression.FirstNoneParenthesisExpression();
            var secondExpression = comparisonExpression.SecondExpression.FirstNoneParenthesisExpression();
            checkHasNullLiteral(firstExpression, secondExpression, comparisonExpression.ComparisonType);
            checkHasNullVariableReference(firstExpression, secondExpression, comparisonExpression.ComparisonType);
        }
Example #12
0
            public override void Visit(BooleanComparisonExpression node)
            {
                var visitor = new ChildFunctionCallVisitor();

                node.Accept(visitor);
                if (visitor.UpperLowerFound)
                {
                    UpperLowerFunctionCallInComparison = true;
                }
            }
Example #13
0
        internal gsWhereTermBase GetWhereTerm(BooleanComparisonExpression booleanComparisonExpression)
        {
            gsWhereTermCompare whereTerm = new gsWhereTermCompare();

            whereTerm.Operator         = booleanComparisonExpression.ComparisonType.ToCompareOperator();
            whereTerm.FirstExpression  = gsScalarExpressionParserFactory.CreateParser(booleanComparisonExpression.FirstExpression, null).Parse();
            whereTerm.SecondExpression = gsScalarExpressionParserFactory.CreateParser(booleanComparisonExpression.SecondExpression, null).Parse();

            return(whereTerm);
        }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            if (node.SecondExpression.FirstNoneParenthesisExpression() is Literal ||
                node.FirstExpression.FirstNoneParenthesisExpression() is Literal)
            {
                IsSuspected = true;
            }

            base.ExplicitVisit(node);
        }
        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);
            }));
        }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            var secondFunction = node.SecondExpression as FunctionCall;
            checkIsSuspected(secondFunction);

            var firstFunction = node.FirstExpression as FunctionCall;
            checkIsSuspected(firstFunction);

            base.ExplicitVisit(node);
        }
Example #17
0
 private BooleanComparisonExpression CreateSearchCondition(string keyColumn, BooleanComparisonExpression condition)
 {
     condition.ComparisonType  = BooleanComparisonType.Equals;
     condition.FirstExpression = new ScalarExpressionSnippet {
         Script = string.Format("{0}.[{1}]", MergeIdentifierStrings.SourceName, keyColumn)
     };
     condition.SecondExpression = new ScalarExpressionSnippet {
         Script = string.Format("{0}.[{1}]", MergeIdentifierStrings.TargetName, keyColumn)
     };
     return(condition);
 }
Example #18
0
 private BooleanComparisonExpression CreateSearchConditionForTableWithNoKeys(BooleanComparisonExpression condition)
 {
     condition.ComparisonType  = BooleanComparisonType.Equals;
     condition.FirstExpression = new ScalarExpressionSnippet {
         Script = string.Format("{0}.{1}", MergeIdentifierStrings.SourceName, "[???]")
     };
     condition.SecondExpression = new ScalarExpressionSnippet {
         Script = string.Format("{0}.{1}", MergeIdentifierStrings.TargetName, "[???]")
     };
     return(condition);
 }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            var secondFunction = node.SecondExpression as FunctionCall;

            checkIsSuspected(secondFunction);

            var firstFunction = node.FirstExpression as FunctionCall;

            checkIsSuspected(firstFunction);

            base.ExplicitVisit(node);
        }
Example #20
0
        private void BuildMultiKeySearchCondition(MergeSpecification specification)
        {
            var comparisons = new List <BooleanComparisonExpression>();

            foreach (var column in _merge.Table.Columns.Where(p => p.IsKey))
            {
                var condition = new BooleanComparisonExpression();
                comparisons.Add(CreateSearchCondition(column.Name.GetName(), condition));
            }

            specification.SearchCondition = CreateExpressionTreeForMultiKeySearchConditon(comparisons).First();
        }
Example #21
0
        private void BuildMultiKeySearchCondition(MergeSpecification specification)
        {
            var comparisons = new List <BooleanComparisonExpression>();

            foreach (var column in _keyColumns)
            {
                var condition = new BooleanComparisonExpression();
                comparisons.Add(CreateSearchCondition(column, condition));
            }

            specification.SearchCondition = CreateExpressionTreeForMultiKeySearchConditon(comparisons).First();
        }
Example #22
0
 public override void Visit(BooleanComparisonExpression exp)
 {
     if (exp.FirstExpression is ColumnReferenceExpression)
     {
         RbacWhereClause aWhereClause = new RbacWhereClause();
         aWhereClause.Literal      = RbacWhereClauseLiterals.BooleanExpression;
         aWhereClause.OnTableAlias = ((ColumnReferenceExpression)exp.FirstExpression).MultiPartIdentifier.Identifiers.First().Value;
         aWhereClause.OnColumn     = ((ColumnReferenceExpression)exp.FirstExpression).MultiPartIdentifier.Identifiers.Last().Value;
         aWhereClause.ConditionValues.Add(((Literal)exp.SecondExpression).Value);
         aWhereClause.WhereClauseString = Query.Substring(exp.StartOffset, exp.FragmentLength);
         WhereClauses.Add(aWhereClause);
     }
 }
Example #23
0
        private void checkForNullLiterals(BooleanComparisonExpression comparisonExpression)
        {
            if (comparisonExpression == null)
            {
                return;
            }

            var firstExpression  = comparisonExpression.FirstExpression.FirstNoneParenthesisExpression();
            var secondExpression = comparisonExpression.SecondExpression.FirstNoneParenthesisExpression();

            checkHasNullLiteral(firstExpression, secondExpression, comparisonExpression.ComparisonType);
            checkHasNullVariableReference(firstExpression, secondExpression, comparisonExpression.ComparisonType);
        }
        private bool TestCompare(BooleanComparisonExpression compare)
        {
            var expr1 = compare.FirstExpression;
            var expr2 = compare.SecondExpression;
            var type1 = expr1.GetType();
            var type2 = expr2.GetType();

            return(
                (
                    (type1 == typeof(IntegerLiteral) || type1 == typeof(StringLiteral)) &&
                    (type2 == typeof(IntegerLiteral) || type2 == typeof(StringLiteral))
                ) &&
                _comparer.Equals((expr1 as Literal)?.Value, (expr2 as Literal)?.Value));
        }
        private BooleanComparisonExpression BuildWhilePredicate(QuerySpecification subQuery)
        {
            var query = new BooleanComparisonExpression();

            query.ComparisonType = BooleanComparisonType.GreaterThan;
            var scalarQuery = (query.FirstExpression = new ScalarSubquery()) as ScalarSubquery;

            scalarQuery.QueryExpression = subQuery;

            query.SecondExpression = new IntegerLiteral
            {
                Value = "0"
            };

            return(query);
        }
Example #26
0
        public override void VisitBooleanComparisonExpression(BooleanComparisonExpression booleanComparisonExpression)
        {
            booleanComparisonExpression.Left.Accept(this);
            booleanComparisonExpression.Right.Accept(this);

            var rightExpression = PopStack();
            var leftExpression  = PopStack();

            var expression = PredicateUtils.CreateComparisonExpression(
                leftExpression,
                rightExpression,
                booleanComparisonExpression.Type,
                _visitorMetadata.OperationsProvider);

            AddExpressionToStack(expression);
        }
Example #27
0
        protected override object InternalVisit(BooleanComparisonExpression node)
        {
            var comparer = SQLComparer.Default;
            Func <object, object, bool> func;

            switch (node.ComparisonType)
            {
            case BooleanComparisonType.Equals:
                func = (first, second) => 0 == comparer.Compare(first, second);
                break;

            case BooleanComparisonType.GreaterThan:
                func = (first, second) => 1 == comparer.Compare(first, second);
                break;

            case BooleanComparisonType.LessThan:
                func = (first, second) => - 1 == comparer.Compare(first, second);
                break;

            case BooleanComparisonType.NotLessThan:
            case BooleanComparisonType.GreaterThanOrEqualTo:
                func = (first, second) => - 1 < comparer.Compare(first, second);
                break;

            case BooleanComparisonType.NotGreaterThan:
            case BooleanComparisonType.LessThanOrEqualTo:
                func = (first, second) => 1 > comparer.Compare(first, second);
                break;

            case BooleanComparisonType.NotEqualToBrackets:
            case BooleanComparisonType.NotEqualToExclamation:
                func = (first, second) => 0 != comparer.Compare(first, second);
                break;

            case BooleanComparisonType.LeftOuterJoin:
            case BooleanComparisonType.RightOuterJoin:
            default:
                throw new NotImplementedException();
            }

            return(new Func <Environment, object>((env) =>
            {
                var first = EvaluateExpression <object>(node.FirstExpression, env);
                var second = EvaluateExpression <object>(node.SecondExpression, env);
                return func(first, second);
            }));
        }
Example #28
0
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            node.FirstExpression.Accept(this);
            switch (node.ComparisonType)
            {
            case BooleanComparisonType.Equals:
                _buffer.Append(" = ");
                break;

            case BooleanComparisonType.GreaterThan:
                _buffer.Append(" > ");
                break;

            case BooleanComparisonType.GreaterThanOrEqualTo:
                _buffer.Append(" >= ");
                break;

            case BooleanComparisonType.LessThan:
                _buffer.Append(" < ");
                break;

            case BooleanComparisonType.LessThanOrEqualTo:
                _buffer.Append(" < ");
                break;

            case BooleanComparisonType.NotEqualToBrackets:
                _buffer.Append(" <> ");
                break;

            case BooleanComparisonType.NotEqualToExclamation:
                _buffer.Append(" != ");
                break;

            case BooleanComparisonType.NotGreaterThan:
                _buffer.Append(" !> ");
                break;

            case BooleanComparisonType.NotLessThan:
                _buffer.Append(" !< ");
                break;

            default:
                throw new InvalidOperationException();
            }
            node.SecondExpression.Accept(this);
        }
Example #29
0
        public void TestStringEqualsNull()
        {
            var actual   = QueryBuilder.BooleanExpression <TestClass>(x => x.String == null);
            var expected = new BooleanComparisonExpression()
            {
                Type = BooleanComparisonType.Equals,
                Left = new ColumnReference()
                {
                    Identifiers = new List <string>()
                    {
                        "String"
                    },
                },
                Right = new NullLiteral()
            };

            actual.Should().BeEquivalentTo(expected, x => x.RespectingRuntimeTypes());
        }
        public void TestVisitBooleanComparisonExpression()
        {
            Mock <ScalarExpression> left  = new Mock <ScalarExpression>();
            Mock <ScalarExpression> right = new Mock <ScalarExpression>();

            BooleanComparisonExpression booleanComparisonExpression = new BooleanComparisonExpression()
            {
                Left  = left.Object,
                Right = right.Object
            };

            KoraliumSqlVisitor koraliumSqlVisitor = new KoraliumSqlVisitor();

            koraliumSqlVisitor.Visit(booleanComparisonExpression);

            left.Verify(x => x.Accept(koraliumSqlVisitor));
            right.Verify(x => x.Accept(koraliumSqlVisitor));
        }
        public override void ExplicitVisit(BooleanComparisonExpression node)
        {
            // ComparisonType + First + Second
            cs.CodeBinaryOperatorExpression binary = new cs.CodeBinaryOperatorExpression();
            binary.Operator = ConvertToBinaryOperatorType(node.ComparisonType);
            binary.Left     = TryBuildFromNode(node.FirstExpression, ref lastHasError, ref lastError);
            binary.Right    = TryBuildFromNode(node.SecondExpression, ref lastHasError, ref lastError);

            if (lastHasError)
            {
                return;
            }

            // adjust left or right : boolean column - compare to int : true==1
            // try get left type
            // try  get right type

            this.lastExpression = binary;
        }
        public IEnumerable <IColumnRelationship> ParseBooleanComparisonExpression(BooleanComparisonExpression booleanComparisonExpression, IDictionary <string, ITable> tableByAliasIdentifier, IList <int> booleanComparisonExpressionIdentifiers, RelationshipOrigin relationshipOrigin)
        {
            if (booleanComparisonExpression.ComparisonType == BooleanComparisonType.NotEqualToBrackets || booleanComparisonExpression.ComparisonType == BooleanComparisonType.NotEqualToExclamation)
            {
                yield break;
            }

            var columnReferenceExpressions = _visitorProvider.GetColumnReferenceExpressions(booleanComparisonExpression).AsList();

            if (columnReferenceExpressions.Count != 2)
            {
                yield break;
            }

            var fromColumnReferenceExpression = columnReferenceExpressions[0];

            if (!TryParseColumn(fromColumnReferenceExpression, tableByAliasIdentifier, out IColumn fromColumn))
            {
                yield break;
            }

            var toColumnReferenceExpression = columnReferenceExpressions[1];

            if (!TryParseColumn(toColumnReferenceExpression, tableByAliasIdentifier, out IColumn toColumn))
            {
                yield break;
            }

            var booleanComparisonExpressionIdentifier = booleanComparisonExpression.FirstTokenIndex + booleanComparisonExpression.LastTokenIndex;

            if (booleanComparisonExpressionIdentifiers.Contains(booleanComparisonExpressionIdentifier))
            {
                yield break;
            }

            booleanComparisonExpressionIdentifiers.Add(booleanComparisonExpressionIdentifier);

            var columnRelationship = new ColumnRelationship(fromColumn, toColumn, relationshipOrigin);

            yield return(columnRelationship);
        }
Example #33
0
        public void TestBooleanComparisionInvertedEquals()
        {
            var actual   = QueryBuilder.BooleanExpression <TestClass>(x => !(x.String == "test"));
            var expected = new BooleanComparisonExpression()
            {
                Type = BooleanComparisonType.NotEqualTo,
                Left = new ColumnReference()
                {
                    Identifiers = new List <string>()
                    {
                        "String"
                    },
                },
                Right = new StringLiteral()
                {
                    Value = "test"
                }
            };

            actual.Should().BeEquivalentTo(expected, x => x.RespectingRuntimeTypes());
        }
Example #34
0
        public void TestBooleanComparisionLessThan()
        {
            var actual   = QueryBuilder.BooleanExpression <TestClass>(x => x.Long < 3);
            var expected = new BooleanComparisonExpression()
            {
                Type = BooleanComparisonType.LessThan,
                Left = new ColumnReference()
                {
                    Identifiers = new List <string>()
                    {
                        "Long"
                    },
                },
                Right = new IntegerLiteral()
                {
                    Value = 3
                }
            };

            actual.Should().BeEquivalentTo(expected, x => x.RespectingRuntimeTypes());
        }
Example #35
0
        private string buildChunkedDelete(DeleteSpecification delete)
        {

            var counter = new DeclareVariableStatement();
            var counterVariable = new DeclareVariableElement();
            counterVariable.DataType = new SqlDataTypeReference() {SqlDataTypeOption = SqlDataTypeOption.Int};
            counterVariable.VariableName = new Identifier() {Value = "@rowcount"};
            counterVariable.Value = new IntegerLiteral() {Value = "10000"};
            counter.Declarations.Add(counterVariable);
            
            delete.TopRowFilter = new TopRowFilter();
            delete.TopRowFilter.Expression = new ParenthesisExpression() {Expression = new IntegerLiteral() {Value = "10000"} };

            var setCounter = new SetVariableStatement();
            setCounter.Variable = new VariableReference() {Name = "@rowcount"};
            setCounter.Expression = new GlobalVariableExpression() {Name = "@@rowcount"};
            setCounter.AssignmentKind = AssignmentKind.Equals;

            var deleteStatement = new DeleteStatement();
            deleteStatement.DeleteSpecification = delete;

            var beginEnd = new BeginEndBlockStatement();
            beginEnd.StatementList = new StatementList();
            beginEnd.StatementList.Statements.Add(deleteStatement);
            beginEnd.StatementList.Statements.Add(setCounter);

            var whilePredicate = new BooleanComparisonExpression();
            whilePredicate.ComparisonType = BooleanComparisonType.GreaterThan;
            whilePredicate.FirstExpression = new VariableReference() {Name = "@rowcount"};
            whilePredicate.SecondExpression = new IntegerLiteral() {Value = "0"};

            var whileStatement = new WhileStatement();
            whileStatement.Predicate = whilePredicate;
            whileStatement.Statement = beginEnd;
            
            var text = ScriptDom.GenerateTSql(counter) + "\r\n" + ScriptDom.GenerateTSql(whileStatement);

            return text;
        }
Example #36
0
        private void BuildEqualsSameLiteral(BooleanExpression search, ScalarExpression firstParam, Literal literal)
        {
            var newExpression = new BooleanParenthesisExpression();
            var expression = new BooleanBinaryExpression();
            newExpression.Expression = expression;

            expression.BinaryExpressionType = BooleanBinaryExpressionType.Or;
            var isnull = new BooleanIsNullExpression();
            isnull.Expression = firstParam;
            expression.FirstExpression = isnull;

            var second = new BooleanComparisonExpression();
            second.FirstExpression = firstParam;
            second.SecondExpression = literal;
            expression.SecondExpression = second;

            var sql = ScriptDom.GenerateTSql(newExpression);

            _replacementsToMake.Add(new Replacements
            {
                Original = _script.Substring(search.StartOffset, search.FragmentLength),
                OriginalLength = search.FragmentLength,
                OriginalOffset = search.StartOffset,
                Replacement = sql,
                OriginalFragment = _currentFragment
            });
        }
 public override void ExplicitVisit(BooleanComparisonExpression node)
 {
     checkForNullLiterals(node);
     base.ExplicitVisit(node);
 }
        private void BuildMultiKeySearchCondition(MergeSpecification specification)
        {
            var comparisons = new List<BooleanComparisonExpression>();
            foreach (var column in _keyColumns)
            {
                var condition = new BooleanComparisonExpression();
                comparisons.Add(CreateSearchCondition(column, condition));
            }

            specification.SearchCondition = CreateExpressionTreeForMultiKeySearchConditon(comparisons).First();
        }
 public override void ExplicitVisit(BooleanComparisonExpression fragment)
 {
     _fragments.Add(fragment);
 }
Example #40
0
        private BooleanComparisonExpression CreateSearchCondition(string keyColumn, BooleanComparisonExpression condition)
        {

            condition.ComparisonType = BooleanComparisonType.Equals;
            condition.FirstExpression = new ScalarExpressionSnippet { Script = string.Format("[{0}].[{1}]", MergeIdentifierStrings.SourceName, keyColumn) };
            condition.SecondExpression = new ScalarExpressionSnippet { Script = string.Format("[{0}].[{1}]", MergeIdentifierStrings.TargetName, keyColumn) };
            return condition;
        }
Example #41
0
        private void BuildMultiKeySearchCondition(MergeSpecification specification)
        {
            var comparisons = new List<BooleanComparisonExpression>();

            foreach (var column in _merge.Table.Columns.Where(p => p.IsKey))
            {
                var condition = new BooleanComparisonExpression();
                comparisons.Add(CreateSearchCondition(column.Name.GetName(), condition));
            }

            specification.SearchCondition = CreateExpressionTreeForMultiKeySearchConditon(comparisons).First();
        }
Example #42
0
 private BooleanComparisonExpression CreateSearchConditionForTableWithNoKeys(BooleanComparisonExpression condition)
 {
     condition.ComparisonType = BooleanComparisonType.Equals;
     condition.FirstExpression = new ScalarExpressionSnippet { Script = string.Format("{0}.{1}", MergeIdentifierStrings.SourceName, "[???]") };
     condition.SecondExpression = new ScalarExpressionSnippet { Script = string.Format("{0}.{1}", MergeIdentifierStrings.TargetName, "[???]") };
     return condition;
 }
        private BooleanComparisonExpression BuildWhilePredicate(QuerySpecification subQuery)
        {
            var query = new BooleanComparisonExpression();
            query.ComparisonType = BooleanComparisonType.GreaterThan;
            var scalarQuery = (query.FirstExpression = new ScalarSubquery()) as ScalarSubquery;
            scalarQuery.QueryExpression = subQuery;

            query.SecondExpression = new IntegerLiteral
            {
                Value = "0"
            };

            return query;
        }
Example #44
0
 public override void Visit(BooleanComparisonExpression node) { this.action(node); }