Ejemplo n.º 1
0
 protected CamlFieldRef GetFieldRef(string fieldName, out FieldType dataType)
 {
     dataType = Microsoft.SharePoint.Client.FieldType.Invalid;
     if (SpQueryArgs != null && !string.IsNullOrEmpty(fieldName))
     {
         if (SpQueryArgs.FieldMappings.ContainsKey(fieldName))
         {
             var fieldMap = SpQueryArgs.FieldMappings[fieldName];
             var fieldRef = new CamlFieldRef()
             {
                 Name = fieldMap.Name
             };
             if (fieldMap is LookupFieldAttribute)
             {
                 if ((fieldMap as LookupFieldAttribute).Result == LookupItemResult.Id)
                 {
                     fieldRef.LookupId = true;
                 }
             }
             dataType = fieldMap.DataType;
             return(fieldRef);
         }
         else
         {
             throw new Exception($"Cannot find '{fieldName}' mapping field. Check '{typeof(FieldAttribute)}'.");
         }
     }
     return(null);
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 protected FieldValueOperator(string operatorName, Guid fieldId, T value, FieldType type)
     : base(operatorName, value, type)
 {
     FieldRef = new CamlFieldRef {
         Id = fieldId
     };
 }
Ejemplo n.º 4
0
 protected FieldValueOperator(string operatorName, string fieldName, T value, FieldType type)
     : base(operatorName, value, type)
 {
     FieldRef = new CamlFieldRef {
         Name = fieldName
     };
 }
Ejemplo n.º 5
0
 protected FieldValueOperator(string operatorName, string fieldName, CamlValue <T> value)
     : base(operatorName, value)
 {
     FieldRef = new CamlFieldRef {
         Name = fieldName
     };
 }
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if ((node.Method.Name == "IsMembership") && typeof(ListItemEntityExtensions).IsAssignableFrom(node.Method.DeclaringType))
            {
                Visit(node.Object);
                foreach (var arg in node.Arguments)
                {
                    if (arg.NodeType == ExpressionType.Constant || arg.NodeType == ExpressionType.Lambda)
                    {
                        Visit(arg);
                    }
                }

                FieldType    dataType;
                CamlFieldRef fieldRef = GetFieldRef(out dataType);

                if (fieldRef == null || FieldValue == null)
                {
                    return(node);
                }

                Operator = new Membership(fieldRef, (MembershipType)FieldValue);
                return(node);
            }
            throw new NotSupportedException($"{node.NodeType} method is not supported in LinqToSP.");
        }
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if ((node.Method.Name == "LookupIncludes" || node.Method.Name == "LookupIdIncludes") && typeof(ListItemEntityExtensions).IsAssignableFrom(node.Method.DeclaringType))
            {
                Visit(node.Object);
                foreach (var arg in node.Arguments)
                {
                    if (arg.NodeType == ExpressionType.Constant || arg.NodeType == ExpressionType.Lambda)
                    {
                        Visit(arg);
                    }
                }

                FieldType    dataType;
                CamlFieldRef fieldRef = GetFieldRef(out dataType);
                CamlValue    value    = GetValue(dataType);
                if (fieldRef == null || value == null)
                {
                    return(node);
                }
                if (node.Method.Name == "LookupIdIncludes")
                {
                    fieldRef.LookupId = true;
                }
                Operator = new Caml.Operators.Includes(fieldRef, value);
                return(node);
            }
            throw new NotSupportedException($"{node.NodeType} method is not supported in LinqToSP.");
        }
Ejemplo n.º 8
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if (node.Method.Name == "DateRangesOverlap" && typeof(ListItemEntityExtensions).IsAssignableFrom(node.Method.DeclaringType))
            {
                Visit(node.Object);
                foreach (var arg in node.Arguments)
                {
                    if (arg.NodeType == ExpressionType.Constant || arg.NodeType == ExpressionType.Lambda)
                    {
                        Visit(arg);
                    }
                }

                FieldType    dataType;
                CamlFieldRef startTimeFieldRef      = GetFieldRef(StartTimeFieldName, out dataType);
                CamlFieldRef endTimeFieldRef        = GetFieldRef(EndTimeFieldName, out dataType);
                CamlFieldRef recurrenceDataFieldRef = GetFieldRef(RecurrenceDataFieldName, out dataType);
                CamlValue    value = GetValue(Microsoft.SharePoint.Client.FieldType.DateTime);
                value.IncludeTimeValue = null;

                if (startTimeFieldRef == null || endTimeFieldRef == null || recurrenceDataFieldRef == null || value == null)
                {
                    return(node);
                }

                Operator = new Caml.Operators.DateRangesOverlap(startTimeFieldRef, endTimeFieldRef, recurrenceDataFieldRef, value);
                return(node);
            }
            throw new NotSupportedException($"{node.NodeType} method is not supported in LinqToSP.");
        }
Ejemplo n.º 9
0
 protected FieldCamlMultiValue(string operatorName, Guid fieldId, IEnumerable <CamlValue <T> > values)
     : base(operatorName, values)
 {
     FieldRef = new CamlFieldRef {
         Id = fieldId
     };
 }
Ejemplo n.º 10
0
 protected FieldCamlMultiValue(string operatorName, string fieldName, IEnumerable <CamlValue <T> > values)
     : base(operatorName, values)
 {
     FieldRef = new CamlFieldRef {
         Name = fieldName
     };
 }
Ejemplo n.º 11
0
 protected FieldValueOperator(string operatorName, Guid fieldId, CamlValue <T> value)
     : base(operatorName, value)
 {
     FieldRef = new CamlFieldRef {
         Id = fieldId
     };
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 protected FieldCamlMultiValue(string operatorName, string fieldName, IEnumerable <T> values,
                               FieldType type)
     : base(operatorName, values, type)
 {
     FieldRef = new CamlFieldRef {
         Name = fieldName
     };
 }
Ejemplo n.º 14
0
 protected FieldCamlMultiValue(string operatorName, Guid fieldId, IEnumerable <T> values,
                               FieldType type)
     : base(operatorName, values, type)
 {
     FieldRef = new CamlFieldRef {
         Id = fieldId
     };
 }
Ejemplo n.º 15
0
 protected override void OnParsing(XElement existingFieldValueOperator)
 {
     var existingFieldRef = existingFieldValueOperator.ElementIgnoreCase(CamlFieldRef.FieldRefTag);
     if (existingFieldRef != null)
     {
         FieldRef = new CamlFieldRef(existingFieldRef);
     }
 }
Ejemplo n.º 16
0
        protected override void OnParsing(XElement existingFieldValueOperator)
        {
            var existingFieldRef = existingFieldValueOperator.ElementIgnoreCase(CamlFieldRef.FieldRefTag);

            if (existingFieldRef != null)
            {
                FieldRef = new CamlFieldRef(existingFieldRef);
            }
        }
Ejemplo n.º 17
0
 protected FieldOperator(string operatorName, CamlFieldRef fieldRef)
     : base(operatorName)
 {
     if (fieldRef == null)
     {
         throw new ArgumentNullException("fieldRef");
     }
     FieldRef = fieldRef;
 }
Ejemplo n.º 18
0
        protected override void OnParsing(XElement existingSingleFieldMultipleValueOperator)
        {
            var existingValues = existingSingleFieldMultipleValueOperator.ElementIgnoreCase(ValuesTag);

            if (existingValues != null)
            {
                base.OnParsing(existingValues);
            }
            var existingFieldRef = existingSingleFieldMultipleValueOperator.ElementIgnoreCase(CamlFieldRef.FieldRefTag);

            if (existingFieldRef != null)
            {
                FieldRef = new CamlFieldRef(existingFieldRef);
            }
        }
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            if (node.Method.Name == "StartsWith")
            {
                Visit(node.Object);
                foreach (var arg in node.Arguments)
                {
                    Visit(arg);
                }

                FieldType    dataType;
                CamlFieldRef fieldRef = GetFieldRef(out dataType);
                CamlValue    value    = GetValue(dataType);
                if (fieldRef == null)
                {
                    return(node);
                }

                Operator = new Caml.Operators.BeginsWith(fieldRef, value);
                return(node);
            }
            throw new NotSupportedException($"{node.NodeType} method is not supported in LinqToSP.");
        }
Ejemplo n.º 20
0
 public In(CamlFieldRef fieldRef, IEnumerable <CamlValue <object> > values) : base(fieldRef, values)
 {
 }
Ejemplo n.º 21
0
 public CamlOrderBy(CamlFieldRef fieldRef)
     : this(new[] {fieldRef})
 {
 }
Ejemplo n.º 22
0
 protected FieldValueOperator(string operatorName, CamlFieldRef fieldRef, CamlValue <T> value)
     : base(operatorName, value)
 {
     FieldRef = fieldRef;
 }
Ejemplo n.º 23
0
 protected FieldValueOperator(string operatorName, CamlFieldRef fieldRef, T value, FieldType type)
     : base(operatorName, value, type)
 {
     FieldRef = fieldRef;
 }
Ejemplo n.º 24
0
 protected FieldCamlMultiValue(string operatorName, CamlFieldRef fieldRef, IEnumerable <CamlValue <T> > values)
     : base(operatorName, values)
 {
     FieldRef = fieldRef;
 }
Ejemplo n.º 25
0
 protected FieldCamlMultiValue(string operatorName, CamlFieldRef fieldRef, IEnumerable <T> values,
                               FieldType type)
     : base(operatorName, values, type)
 {
     FieldRef = fieldRef;
 }
Ejemplo n.º 26
0
 public Lt(CamlFieldRef fieldRef, object value, FieldType type)
     : base(fieldRef, value, type)
 {
 }
Ejemplo n.º 27
0
 public Lt(CamlFieldRef fieldRef, CamlValue <object> value) : base(fieldRef, value)
 {
 }
Ejemplo n.º 28
0
 public IsNotNull(CamlFieldRef fieldRef)
     : base(IsNotNullTag, fieldRef)
 {
 }
Ejemplo n.º 29
0
 public DateRangesOverlap(CamlFieldRef startField, CamlFieldRef endField, CamlFieldRef recurrenceIdField,
                          CamlValue value)
     : base(DateRangesOverlapTag, new[] { startField, endField, recurrenceIdField }, value, FieldType.DateTime)
 {
 }
Ejemplo n.º 30
0
 public IsNotNull(CamlFieldRef fieldRef)
     : base(IsNotNullTag, fieldRef)
 {
 }
Ejemplo n.º 31
0
 public Contains(CamlFieldRef fieldRef, CamlValue <string> value)
     : base(fieldRef, value)
 {
 }
Ejemplo n.º 32
0
 public Contains(CamlFieldRef fieldRef, string value)
     : base(fieldRef, value, FieldType.Text)
 {
 }
Ejemplo n.º 33
0
 public CamlGroupBy(CamlFieldRef fieldRef, bool? collapse = null, int? limit = 30)
     : this(new[] { fieldRef }, collapse, limit)
 {
 }
Ejemplo n.º 34
0
 public In(CamlFieldRef fieldRef, IEnumerable <object> values, FieldType type)
     : base(fieldRef, values, type)
 {
 }
Ejemplo n.º 35
0
 protected FieldOperator(string operatorName, CamlFieldRef fieldRef)
     : base(operatorName)
 {
     if (fieldRef == null) throw new ArgumentNullException(nameof(fieldRef));
     FieldRef = fieldRef;
 }
Ejemplo n.º 36
0
 public Membership(CamlFieldRef fieldRef, MembershipType membershipType)
     : base(MembershipTag, fieldRef)
 {
     MembershipType = membershipType;
 }