示例#1
0
        protected override Expression VisitBinary(BinaryExpression exp)
        {
            LeftOperator  = ToOperator(exp.Left);
            RightOperator = ToOperator(exp.Right);
            FieldType    dataType;
            CamlFieldRef fieldRef = GetFieldRef(out dataType);
            CamlValue    value    = GetValue(dataType);

            if (fieldRef == null)
            {
                return(exp);
            }
            switch (exp.NodeType)
            {
            case ExpressionType.Equal:
                if (exp.Right.IsNullValue())
                {
                    Operator = new Caml.Operators.IsNull(fieldRef);
                }
                else
                {
                    Operator = new Caml.Operators.Eq(fieldRef, value);
                }
                break;

            case ExpressionType.NotEqual:
                if (exp.Right.IsNullValue())
                {
                    Operator = new Caml.Operators.IsNotNull(fieldRef);
                }
                else
                {
                    Operator = new Caml.Operators.Neq(fieldRef, value);
                }
                break;

            case ExpressionType.GreaterThan:
                Operator = new Caml.Operators.Gt(fieldRef, value);
                break;

            case ExpressionType.GreaterThanOrEqual:
                Operator = new Caml.Operators.Geq(fieldRef, value);
                break;

            case ExpressionType.LessThan:
                Operator = new Caml.Operators.Lt(fieldRef, value);
                break;

            case ExpressionType.LessThanOrEqual:
                Operator = new Caml.Operators.Leq(fieldRef, value);
                break;

            //case ExpressionType.Convert:
            //    Visit(exp);
            //    break;
            default:
                throw new NotSupportedException($"{exp.NodeType} operator is not supported in LinqToSP.");
            }
            return(exp);
        }
示例#2
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            Expression expression = node;

            if (node.Method.Name == "Equals")
            {
                foreach (var arg in node.Arguments)
                {
                    Visit(arg);
                }

                FieldType    dataType;
                CamlFieldRef fieldRef = GetFieldRef(out dataType);
                CamlValue    value    = GetValue(dataType);

                Operator = new Caml.Operators.Eq(fieldRef, value);
            }
            else if (node.Method.Name == "NotEquals")
            {
                Visit(node.Object);
                foreach (var arg in node.Arguments)
                {
                    Visit(arg);
                }

                FieldType    dataType;
                CamlFieldRef fieldRef = GetFieldRef(out dataType);
                CamlValue    value    = GetValue(dataType);

                Operator = new Caml.Operators.Neq(fieldRef, value);
                //return null;
            }
            return(expression);
        }