Пример #1
0
        public override SqlExpression VisitConditional(SqlConditionalExpression conditional)
        {
            var evalTest = Visit(conditional.TestExpression);

            if (evalTest.ExpressionType != SqlExpressionType.Constant)
            {
                throw new ExpressionEvaluateException("The test expression of a conditional must evaluate to a constant value.");
            }

            var evalTestValue = ((SqlConstantExpression)evalTest).Value;

            if (!(evalTestValue.Type is BooleanType))
            {
                throw new ExpressionEvaluateException("The test expression of a conditional must be a boolean value.");
            }

            if (evalTestValue)
            {
                return(Visit(conditional.TrueExpression));
            }

            if (conditional.FalseExpression != null)
            {
                return(Visit(conditional.FalseExpression));
            }

            return(SqlExpression.Constant(PrimitiveTypes.Null()));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="conditional"></param>
        /// <returns></returns>
        public virtual SqlExpression VisitConditional(SqlConditionalExpression conditional)
        {
            var test    = conditional.TestExpression;
            var ifTrue  = conditional.TrueExpression;
            var ifFalse = conditional.FalseExpression;

            if (test != null)
            {
                test = Visit(test);
            }
            if (ifTrue != null)
            {
                ifTrue = Visit(ifTrue);
            }
            if (ifFalse != null)
            {
                ifFalse = Visit(ifFalse);
            }

            return(SqlExpression.Conditional(test, ifTrue, ifFalse));
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="conditional"></param>
        /// <returns></returns>
        public virtual SqlExpression VisitConditional(SqlConditionalExpression conditional)
        {
            var test = conditional.TestExpression;
            var ifTrue = conditional.TrueExpression;
            var ifFalse = conditional.FalseExpression;

            if (test != null)
                test = Visit(test);
            if (ifTrue != null)
                ifTrue = Visit(ifTrue);
            if (ifFalse != null)
                ifFalse = Visit(ifFalse);

            return SqlExpression.Conditional(test, ifTrue, ifFalse);
        }
        public override SqlExpression VisitConditional(SqlConditionalExpression conditional)
        {
            var evalTest = Visit(conditional.TestExpression);
            if (evalTest.ExpressionType != SqlExpressionType.Constant)
                throw new ExpressionEvaluateException("The test expression of a conditional must evaluate to a constant value.");

            var evalTestValue = ((SqlConstantExpression) evalTest).Value;
            if (!(evalTestValue.Type is BooleanType))
                throw new ExpressionEvaluateException("The test expression of a conditional must be a boolean value.");

            if (evalTestValue)
                return Visit(conditional.TrueExpression);

            if (conditional.FalseExpression != null)
                return Visit(conditional.FalseExpression);

            return SqlExpression.Constant(PrimitiveTypes.Null());
        }
 public override SqlExpression VisitConditional(SqlConditionalExpression conditional)
 {
     return base.VisitConditional(conditional);
 }
Пример #6
0
 public override SqlExpression VisitConditional(SqlConditionalExpression conditional)
 {
     return(base.VisitConditional(conditional));
 }