private WhereModel TranslateCall([NotNull] MethodCallExpression callNode)
 {
     if (MethodUtils.IsOperator(callNode.Method, MethodUtils.EContains))
     {
         return(new ComparisonModel(ComparisonOperator.ContainsOrIncludes,
                                    CamlProcessorUtils.GetFieldRef(callNode.Arguments[0]),
                                    GetValue(callNode.Arguments[1])));
     }
     if (MethodUtils.IsOperator(callNode.Method, MethodUtils.ListContains))
     {
         return(new ComparisonModel(ComparisonOperator.ContainsOrIncludes,
                                    CamlProcessorUtils.GetFieldRef(callNode.Object),
                                    GetValue(callNode.Arguments[0])));
     }
     if (callNode.Method == MethodUtils.StrContains)
     {
         return(TranslateStrContains(callNode));
     }
     if (callNode.Method == MethodUtils.StrStartsWith)
     {
         return(TranslateStrStartsWith(callNode));
     }
     if (callNode.Method.Name == "Contains" &&
         callNode.Object != null &&
         (callNode.Object.Type.IsArray || callNode.Object.Type.IsIEnumerable()) &&
         callNode.Arguments.Count == 1)
     {
         return(new ComparisonModel(ComparisonOperator.ContainsOrIncludes,
                                    CamlProcessorUtils.GetFieldRef(callNode.Object),
                                    GetValue(callNode.Arguments[0])));
     }
     throw Error.SubqueryNotSupported(callNode);
 }
        private WhereModel TranslateComparisonWithNull([NotNull] BinaryExpression binaryNode)
        {
            var fieldRef = CamlProcessorUtils.GetFieldRef(binaryNode.Left);

            if (NullComparisonMap.ContainsKey(binaryNode.NodeType))
            {
                return(new ComparisonModel(NullComparisonMap[binaryNode.NodeType], fieldRef, null));
            }
            throw Error.SubqueryNotSupported(binaryNode);
        }
 private WhereModel TranslateComparison([NotNull] BinaryExpression binaryNode)
 {
     if (ComparisonMap.ContainsKey(binaryNode.NodeType))
     {
         if (binaryNode.Right.IsConstant(null))
         {
             return(TranslateComparisonWithNull(binaryNode));
         }
         var fieldRef = CamlProcessorUtils.GetFieldRef(binaryNode.Left);
         return(new ComparisonModel(ComparisonMap[binaryNode.NodeType], fieldRef, GetValue(binaryNode.Right)));
     }
     throw Error.SubqueryNotSupported(binaryNode);
 }
Example #4
0
        public MemberRefModel Process([NotNull] Expression predicate)
        {
            Guard.CheckNotNull(nameof(predicate), predicate);

            Logger.Trace(LogCategories.FieldSelectorProcessor, "Original predicate:\n{0}", predicate);

            predicate = predicate.StripQuotes();
            if (predicate.NodeType == ExpressionType.Lambda)
            {
                predicate = ((LambdaExpression)predicate).Body;
            }

            var result = CamlProcessorUtils.GetFieldRef(predicate);

            Logger.Trace(LogCategories.FieldSelectorProcessor, "Selectable field in predicate:\n{0}", result);

            return(result);
        }
 private WhereModel TranslateStrStartsWith([NotNull] MethodCallExpression callNode)
 {
     return(new ComparisonModel(ComparisonOperator.BeginsWith,
                                CamlProcessorUtils.GetFieldRef(callNode.Object),
                                GetValue(callNode.Arguments[0])));
 }
        private WhereModel TranslateTrueProperty([NotNull] MemberExpression memberNode)
        {
            var fieldRef = CamlProcessorUtils.GetFieldRef(memberNode);

            return(new ComparisonModel(ComparisonOperator.Eq, fieldRef, true));
        }