Unary() public static méthode

public static Unary ( SqlExpressionType expressionType, SqlExpression operand ) : SqlUnaryExpression
expressionType SqlExpressionType
operand SqlExpression
Résultat SqlUnaryExpression
Exemple #1
0
            public override SqlUnaryExpression Deserialize(BinaryReader reader)
            {
                var expType = (SqlExpressionType)reader.ReadByte();
                var exp     = ReadExpression(reader);

                return(SqlExpression.Unary(expType, exp));
            }
        public static void CreateUnary(SqlExpressionType expressionType, object value)
        {
            var obj     = SqlObject.New(SqlValueUtil.FromObject(value));
            var operand = SqlExpression.Constant(obj);
            var exp     = SqlExpression.Unary(expressionType, operand);

            Assert.NotNull(exp.Operand);
            Assert.IsType <SqlConstantExpression>(exp.Operand);
        }
        public static void GetUnaryType(SqlExpressionType expressionType, object value)
        {
            var obj     = SqlObject.New(SqlValueUtil.FromObject(value));
            var operand = SqlExpression.Constant(obj);
            var exp     = SqlExpression.Unary(expressionType, operand);

            var sqlType = exp.Type;

            Assert.Equal(obj.Type, sqlType);
        }
        public static void GetUnaryString(SqlExpressionType expressionType, object value, string expected)
        {
            var obj     = SqlObject.New(SqlValueUtil.FromObject(value));
            var operand = SqlExpression.Constant(obj);
            var exp     = SqlExpression.Unary(expressionType, operand);

            var s = exp.ToString();

            Assert.Equal(expected, s);
        }
        public static void SerializeUnary(SqlExpressionType expressionType, object value)
        {
            var obj     = SqlObject.New(SqlValueUtil.FromObject(value));
            var operand = SqlExpression.Constant(obj);
            var exp     = SqlExpression.Unary(expressionType, operand);

            var result = BinarySerializeUtil.Serialize(exp);

            Assert.Equal(exp.ExpressionType, result.ExpressionType);
        }
Exemple #6
0
        public virtual SqlExpression VisitUnary(SqlUnaryExpression expression)
        {
            var operand = expression.Operand;

            if (operand != null)
            {
                operand = Visit(operand);
            }

            return(SqlExpression.Unary(expression.ExpressionType, operand));
        }
        public static async Task ReduceUnary(SqlExpressionType expressionType, object value, object expected)
        {
            var obj     = SqlObject.New(SqlValueUtil.FromObject(value));
            var operand = SqlExpression.Constant(obj);
            var exp     = SqlExpression.Unary(expressionType, operand);

            Assert.NotNull(exp.Operand);
            Assert.IsType <SqlConstantExpression>(exp.Operand);

            Assert.True(exp.CanReduce);

            var reduced = await exp.ReduceAsync(null);

            Assert.NotNull(reduced);
            Assert.IsType <SqlConstantExpression>(reduced);

            var expectedResult = SqlObject.New(SqlValueUtil.FromObject(expected));

            Assert.Equal(expectedResult, ((SqlConstantExpression)reduced).Value);
        }
Exemple #8
0
        public static void VisitUnary()
        {
            var exp = SqlExpression.Unary(SqlExpressionType.UnaryPlus, SqlExpression.Constant(SqlObject.Integer(33)));

            Visit(exp);
        }