Beispiel #1
0
 public override VfpExpression Visit(DbComparisonExpression expression)
 {
     return(new VfpComparisonExpression((VfpExpressionKind)expression.ExpressionKind,
                                        expression.ResultType,
                                        expression.Left.Accept(this),
                                        expression.Right.Accept(this)));
 }
Beispiel #2
0
        public override LegacyCommandTrees.DbExpression Visit(DbComparisonExpression expression)
        {
            Debug.Assert(expression != null, "expression != null");

            var a = expression.Left.Accept(this);
            var b = expression.Right.Accept(this);

            switch (expression.ExpressionKind)
            {
            case DbExpressionKind.Equals:
                return(a.Equal(b));

            case DbExpressionKind.NotEquals:
                return(a.NotEqual(b));

            case DbExpressionKind.GreaterThan:
                return(a.GreaterThan(b));

            case DbExpressionKind.GreaterThanOrEquals:
                return(a.GreaterThanOrEqual(b));

            case DbExpressionKind.LessThan:
                return(a.LessThan(b));

            case DbExpressionKind.LessThanOrEquals:
                return(a.LessThanOrEqual(b));
            }

            Debug.Fail("Unknown comparison operator.");

            throw new NotSupportedException();
        }
Beispiel #3
0
        public override void Visit(DbComparisonExpression e)
        {
            Check.NotNull(e, "e");

            BeginBinary(e);
            End(e);
        }
Beispiel #4
0
        public override ISqlFragment Visit(DbComparisonExpression e)
        {
            switch (e.ExpressionKind)
            {
            case DbExpressionKind.Equals:
                return(VisitBinaryExpression("=", e.Left, e.Right));

            case DbExpressionKind.LessThan:
                return(VisitBinaryExpression("<", e.Left, e.Right));

            case DbExpressionKind.LessThanOrEquals:
                return(VisitBinaryExpression("<=", e.Left, e.Right));

            case DbExpressionKind.GreaterThan:
                return(VisitBinaryExpression(">", e.Left, e.Right));

            case DbExpressionKind.GreaterThanOrEquals:
                return(VisitBinaryExpression(">=", e.Left, e.Right));

            // The parser does not generate the expression kind below.
            case DbExpressionKind.NotEquals:
                return(VisitBinaryExpression("<>", e.Left, e.Right));

            default:
                throw new InvalidOperationException(String.Empty);
            }
        }
            /// <summary>
            ///     Determines whether the row being evaluated has the given type (declared in the IsOf predicate).
            /// </summary>
            /// <param name="predicate"> Equals predicate. </param>
            /// <returns> True if the values being compared are equivalent; false otherwise. </returns>
            public override PropagatorResult Visit(DbComparisonExpression predicate)
            {
                Check.NotNull(predicate, "predicate");

                if (DbExpressionKind.Equals
                    == predicate.ExpressionKind)
                {
                    // Retrieve the left and right hand sides of the equality predicate.
                    var leftResult  = Visit(predicate.Left);
                    var rightResult = Visit(predicate.Right);

                    bool?result;

                    if (leftResult.IsNull ||
                        rightResult.IsNull)
                    {
                        result = null; // unknown
                    }
                    else
                    {
                        var left  = leftResult.GetSimpleValue();
                        var right = rightResult.GetSimpleValue();

                        // Perform a comparison between the sides of the equality predicate using invariant culture.
                        // See assumptions outlined in the documentation for this class for additional information.
                        result = ByValueEqualityComparer.Default.Equals(left, right);
                    }

                    return(ConvertBoolToResult(result, leftResult, rightResult));
                }
                else
                {
                    throw ConstructNotSupportedException(predicate);
                }
            }
Beispiel #6
0
 public override void Visit(DbComparisonExpression expression)
 {
     Write(expression);
     _depth++;
     Write("Left", expression.Left);
     Write("Right", expression.Right);
     _depth--;
 }
        public override Expression Visit(DbComparisonExpression expression)
        {
            Expression left = this.Visit(expression.Left);
            Expression right = this.Visit(expression.Right);

            ExpressionHelper.TryUnifyValueTypes(ref left, ref right);

            return this.CreateComparison(left, right, expression.ExpressionKind);
        }
        public override Expression Visit(DbComparisonExpression expression)
        {
            Expression left  = this.Visit(expression.Left);
            Expression right = this.Visit(expression.Right);

            ExpressionHelper.TryUnifyValueTypes(ref left, ref right);

            return(this.CreateComparison(left, right, expression.ExpressionKind));
        }
            public override void Visit(DbComparisonExpression expression)
            {
                Debug.Assert(expression.ExpressionKind == DbExpressionKind.Equals,
                             "only equals comparison expressions are produced in DML command trees in V1");

                VisitBinary(expression, " = ");

                RegisterMemberValue(expression.Left, expression.Right);
            }
Beispiel #10
0
        /// <summary>
        /// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbComparisonExpression"/>.
        /// </summary>
        /// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.Db ComparisonExpression"/> that is visited.</param>
        public override void Visit(DbComparisonExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            expression.Left.Accept(this);
            expression.Right.Accept(this);
        }
 public override DbExpression Visit(DbComparisonExpression expression)
 {
     if (IsString(expression.Left.ResultType) && IsString(expression.Right.ResultType))
     {
         var left  = expression.Left;
         var right = expression.Right;
         if (RemoveCast(ref right) || RemoveCast(ref left))
         {
             return(CreateComparison(expression.ExpressionKind, left, right));
         }
     }
     return(base.Visit(expression));
 }
Beispiel #12
0
        public override DbExpression Visit(DbComparisonExpression expression)
        {
            DbComparisonExpression left1 = (DbComparisonExpression)base.Visit(expression);
            DbPropertyExpression   left2 = (DbPropertyExpression)left1.Left;

            if (!((EdmProperty)left2.Property).Nullable)
            {
                return((DbExpression)left1);
            }
            DbAndExpression dbAndExpression = left2.IsNull().And((DbExpression)left1.Right.IsNull());

            return((DbExpression)left1.Or((DbExpression)dbAndExpression));
        }
            public override void Visit(DbComparisonExpression comparisonExpression)
            {
                EdmMember property = ((DbPropertyExpression)comparisonExpression.Left).Property;

                if (!this._baseTable.KeyMembers.Contains(property))
                {
                    return;
                }
                this._where.Append(" AND t0.");
                this._where.Append(SqlGenerator.QuoteIdentifier(property.Name));
                this._where.Append(" = ");
                comparisonExpression.Right.Accept((DbExpressionVisitor)this);
            }
Beispiel #14
0
                /// <summary>
                /// Perform work for an equality expression node.
                /// </summary>
                /// <param name="node">Equality expresion node</param>
                /// <returns>Results ignored by this visitor implementation.</returns>
                public override object Visit(DbComparisonExpression node)
                {
                    EntityUtil.CheckArgumentNull(node, "node");

                    if (DbExpressionKind.Equals == node.ExpressionKind)
                    {
                        m_leftKeySelectors.Add(node.Left);
                        m_rightKeySelectors.Add(node.Right);
                        return(null);
                    }
                    else
                    {
                        throw ConstructNotSupportedException(node);
                    }
                }
            public override void Visit(DbComparisonExpression comparisonExpression)
            {
                DebugCheck.NotNull(comparisonExpression);

                var property
                    = ((DbPropertyExpression)comparisonExpression.Left).Property;

                if (_baseTable.KeyMembers.Contains(property))
                {
                    _where.Append(" AND t0.");
                    _where.Append(SqlGenerator.QuoteIdentifier(property.Name));
                    _where.Append(" = ");

                    comparisonExpression.Right.Accept(this);
                }
            }
        public override DbExpression Visit(DbComparisonExpression expression)
        {
            var equalityPredicate = (DbComparisonExpression)base.Visit(expression);

            var propertyExpression = (DbPropertyExpression)equalityPredicate.Left;
            var property           = (EdmProperty)propertyExpression.Property;

            if (property.Nullable)
            {
                // Rewrite to IS NULL

                var nullPredicate
                    = propertyExpression.IsNull().And(equalityPredicate.Right.IsNull());

                return(equalityPredicate.Or(nullPredicate));
            }

            return(equalityPredicate);
        }
        private void ConvertAndVerifyComparisonExpression(DbComparisonExpression comparisonExpression)
        {
            var legacyComparisonExpression =
                _legacyDbExpressionConverter.Visit(comparisonExpression) as LegacyCommandTrees.DbComparisonExpression;

            Assert.NotNull(legacyComparisonExpression);
            Assert.Equal((int)comparisonExpression.ExpressionKind, (int)legacyComparisonExpression.ExpressionKind);
            Assert.Equal(LegacyCommandTrees.DbExpressionKind.Constant, legacyComparisonExpression.Left.ExpressionKind);
            Assert.Equal(
                ((DbConstantExpression)comparisonExpression.Left).Value,
                ((LegacyCommandTrees.DbConstantExpression)legacyComparisonExpression.Left).Value);
            Assert.Equal(LegacyCommandTrees.DbExpressionKind.Constant, legacyComparisonExpression.Right.ExpressionKind);
            Assert.Equal(
                ((DbConstantExpression)comparisonExpression.Right).Value,
                ((LegacyCommandTrees.DbConstantExpression)legacyComparisonExpression.Right).Value);

            TypeUsageVerificationHelper
            .VerifyTypeUsagesEquivalent(legacyComparisonExpression.ResultType, comparisonExpression.ResultType);
        }
Beispiel #18
0
            public override DbExpressionEntitySetInfo Visit(DbComparisonExpression expression)
            {
                Check.NotNull(expression, "expression");

                return(null);
            }
Beispiel #19
0
 public override SqlFragment Visit(DbComparisonExpression expression)
 {
     return(VisitBinaryExpression(expression.Left, expression.Right,
                                  Metadata.GetOperator(expression.ExpressionKind)));
 }
Beispiel #20
0
 public override TreeNode Visit(DbComparisonExpression e)
 {
     Check.NotNull <DbComparisonExpression>(e, nameof(e));
     return(this.VisitInfix(e.Left, ExpressionPrinter.PrinterVisitor._opMap[e.ExpressionKind], e.Right));
 }
 /// <summary>
 ///     Visitor pattern method for <see cref="DbComparisonExpression" />.
 /// </summary>
 /// <param name="expression"> The DbComparisonExpression that is being visited. </param>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="expression" />
 ///     is null
 /// </exception>
 public override void Visit(DbComparisonExpression expression)
 {
     VisitBinaryExpression(expression);
 }
 public override void Visit(DbComparisonExpression e)
 {
     BeginBinary(e);
     End(e);
 }
 public override void Visit(DbComparisonExpression expression)
 {
     this.VisitBinary((DbBinaryExpression)expression, " = ");
     this.RegisterMemberValue(expression.Left, expression.Right);
 }
        public override void Visit(DbComparisonExpression e)
        {
            Check.NotNull(e, "e");

            VisitBinary(e);
        }
Beispiel #25
0
 public override object Visit(DbComparisonExpression expression)
 {
     this.Visit(expression.Left);
     this.Visit(expression.Right);
     return(null);
 }
        /// <summary>
        ///     Visitor pattern method for <see cref="DbComparisonExpression" />.
        /// </summary>
        /// <param name="expression"> The DbComparisonExpression that is being visited. </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="expression" />
        ///     is null
        /// </exception>
        public override void Visit(DbComparisonExpression expression)
        {
            Check.NotNull(expression, "expression");

            VisitBinaryExpression(expression);
        }
Beispiel #27
0
 /// <summary>
 ///     Visitor pattern method for DbComparisonExpression.
 /// </summary>
 /// <param name="expression"> The DbComparisonExpression that is being visited. </param>
 public abstract void Visit(DbComparisonExpression expression);
Beispiel #28
0
 public override void Visit(DbComparisonExpression e)
 {
     Check.NotNull <DbComparisonExpression>(e, nameof(e));
     this.VisitBinary((DbBinaryExpression)e);
 }
Beispiel #29
0
 /// <summary>
 ///     Typed visitor pattern method for DbComparisonExpression.
 /// </summary>
 /// <param name="expression"> The DbComparisonExpression that is being visited. </param>
 /// <returns> An instance of TResultType. </returns>
 public abstract TResultType Visit(DbComparisonExpression expression);
 public override void Visit(DbComparisonExpression e)
 {
     VisitBinary(e);
 }
Beispiel #31
0
 public override bool Visit(DbComparisonExpression expression)
 {
     return(VisitBinaryExpression(expression));
 }
Beispiel #32
0
            public override TreeNode Visit(DbComparisonExpression e)
            {
                Check.NotNull(e, "e");

                return(VisitInfix(e.Left, _opMap[e.ExpressionKind], e.Right));
            }
 public override TReturn Visit(DbComparisonExpression expression)
 {
     throw ConstructNotSupportedException(expression);
 }
Beispiel #34
0
 public override void Visit(DbComparisonExpression e)
 {
     VisitBinary(e);
 }
        private void ConvertAndVerifyComparisonExpression(DbComparisonExpression comparisonExpression)
        {
            var legacyComparisonExpression =
                _legacyDbExpressionConverter.Visit(comparisonExpression) as LegacyCommandTrees.DbComparisonExpression;

            Assert.NotNull(legacyComparisonExpression);
            Assert.Equal((int)comparisonExpression.ExpressionKind, (int)legacyComparisonExpression.ExpressionKind);
            Assert.Equal(LegacyCommandTrees.DbExpressionKind.Constant, legacyComparisonExpression.Left.ExpressionKind);
            Assert.Equal(
                ((DbConstantExpression)comparisonExpression.Left).Value,
                ((LegacyCommandTrees.DbConstantExpression)legacyComparisonExpression.Left).Value);
            Assert.Equal(LegacyCommandTrees.DbExpressionKind.Constant, legacyComparisonExpression.Right.ExpressionKind);
            Assert.Equal(
                ((DbConstantExpression)comparisonExpression.Right).Value,
                ((LegacyCommandTrees.DbConstantExpression)legacyComparisonExpression.Right).Value);

            TypeUsageVerificationHelper
                .VerifyTypeUsagesEquivalent(legacyComparisonExpression.ResultType, comparisonExpression.ResultType);
        }
Beispiel #36
0
        /// <summary>
        /// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbComparisonExpression"/>.
        /// </summary>
        /// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.Db ComparisonExpression"/> that is visited.</param>
        public override void Visit(DbComparisonExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            expression.Left.Accept(this);
            expression.Right.Accept(this);
        }
Beispiel #37
0
 public override bool Visit(DbComparisonExpression expression)
 {
     Check.NotNull <DbComparisonExpression>(expression, nameof(expression));
     return(this.VisitBinaryExpression((DbBinaryExpression)expression));
 }
            public override void Visit(DbComparisonExpression comparisonExpression)
            {
                DebugCheck.NotNull(comparisonExpression);

                var property
                    = ((DbPropertyExpression)comparisonExpression.Left).Property;

                if (_baseTable.KeyMembers.Contains(property))
                {
                    _where.Append(" AND t0.");
                    _where.Append(SqlGenerator.QuoteIdentifier(property.Name));
                    _where.Append(" = ");

                    comparisonExpression.Right.Accept(this);
                }
            }
 public override void Visit(DbComparisonExpression expression) { }
Beispiel #40
0
 public override DbExpressionEntitySetInfo Visit(DbComparisonExpression expression)
 {
     return(null);
 }
 public override void Visit(DbComparisonExpression expression)
 {
     Contract.Requires(expression != null);
 }
            public override void Visit(DbComparisonExpression expression)
            {
                Debug.Assert(
                    expression.ExpressionKind == DbExpressionKind.Equals,
                    "only equals comparison expressions are produced in DML command trees in V1");

                VisitBinary(expression, " = ");

                RegisterMemberValue(expression.Left, expression.Right);
            }
 /// <summary>
 ///     Visitor pattern method for DbComparisonExpression.
 /// </summary>
 /// <param name="expression"> The DbComparisonExpression that is being visited. </param>
 public abstract void Visit(DbComparisonExpression expression);