private string GetKqlOperator(CamlBinaryOperator value) { switch (value) { case CamlBinaryOperator.Eq: return("="); case CamlBinaryOperator.Neq: return("<>"); case CamlBinaryOperator.Geq: return(">="); case CamlBinaryOperator.Gt: return(">"); case CamlBinaryOperator.Leq: return("<="); case CamlBinaryOperator.Lt: return("<"); case CamlBinaryOperator.Contains: case CamlBinaryOperator.BeginsWith: return(":"); default: throw new NotSupportedException(String.Format("Unsupported {0} binary operator", value)); } }
private CamlExpression HandleEqualityComparison(SPModelQueryFieldInfo s, CamlBinaryOperator op) { ICamlParameterBinding value = currentScope.GetValueBinding(s); CamlExpression expression = new CamlWhereBinaryComparisonExpression(op, s.FieldRef, value); Type memberType = currentScope.MemberType; if (memberType.IsGenericType && memberType.GetGenericTypeDefinition() == typeof(Nullable <>)) { memberType = memberType.GetGenericArguments()[0]; } if (memberType.IsValueType || memberType == typeof(string)) { string defaultValue = value.Bind(new Hashtable { { currentScope.ParameterName, memberType.IsValueType ? memberType.GetDefaultValue() : "" } }); CamlExpression lateBoundCond = new CamlLateBoundDefaultValueAsNullExpression(s.FieldRef, value, defaultValue); return(op == CamlBinaryOperator.Eq ? expression | lateBoundCond : expression& ~lateBoundCond); } return(expression); }
/// <summary> /// Called when visiting a binary expression inside a <Where/> element. /// </summary> /// <param name="operatorValue">Type of binary operator.</param> /// <param name="fieldName">Name of field.</param> /// <param name="value">Value to operate against the field.</param> /// <param name="includeTimeValue">Indicates whether time component is included in comparison.</param> protected internal abstract void VisitWhereBinaryComparisonExpression(CamlBinaryOperator operatorValue, CamlParameterBindingFieldRef fieldName, ICamlParameterBinding value, bool?includeTimeValue);