public virtual Expression VisitCamlComparison(CamlComparisonExpression node) { string[] parts = SPQueryNodeTypeMapping[node.SPNodeType].Split('|'); string comparison = parts[0]; CamlValueExpression valueExp; CamlFieldExpression fieldExp; if (node.Value is CamlValueExpression) { valueExp = (CamlValueExpression)node.Value; fieldExp = (CamlFieldExpression)node.Field; } else { valueExp = (CamlValueExpression)node.Field; fieldExp = (CamlFieldExpression)node.Value; if (parts.Length > 1) { comparison = parts[1]; } } _whereXml.AppendFormat("<{0}>", comparison); _whereXml.AppendFormat("<FieldRef Name='{0}'/>", fieldExp.Name); _whereXml.AppendFormat("<Value Type='{0}'{1}>{2}</Value>", fieldExp.FieldType.ToString(), node.IncludeTimeValue ? " IncludeTimeValue='TRUE'" : string.Empty, valueExp.ValueString); _whereXml.AppendFormat("</{0}>", comparison); return(node); }
protected override Expression VisitUnary(UnaryExpression node) { if (node.NodeType == ExpressionType.Not && node.Operand.Type.Equals(typeof(bool))) { _withinExpression = true; CamlComparisonExpression exp = new CamlComparisonExpression(SPQueryNodeType.Equals, Visit(node.Operand), new CamlValueExpression(false, node.Type)); _withinExpression = false; return(exp); } throw new NotSupportedException(); }
protected override Expression VisitMethodCall(MethodCallExpression node) { _withinExpression = true; CamlComparisonExpression comparison = null; switch (node.Method.Name) { case "Contains": comparison = new CamlComparisonExpression(SPQueryNodeType.Contains, Visit(node.Object), Visit(node.Arguments[0])); break; case "Equals": comparison = new CamlComparisonExpression(SPQueryNodeType.Equals, Visit(node.Object), Visit(node.Arguments[0])); break; case "QueryEq": comparison = new CamlComparisonExpression(SPQueryNodeType.Equals, Visit(node.Arguments[0]), Visit(node.Arguments[1]), (bool)((ConstantExpression)node.Arguments[2]).Value); break; case "QueryLt": comparison = new CamlComparisonExpression(SPQueryNodeType.LessThan, Visit(node.Arguments[0]), Visit(node.Arguments[1]), (bool)((ConstantExpression)node.Arguments[2]).Value); break; case "QueryGt": comparison = new CamlComparisonExpression(SPQueryNodeType.GreaterThan, Visit(node.Arguments[0]), Visit(node.Arguments[1]), (bool)((ConstantExpression)node.Arguments[2]).Value); break; case "QueryLeq": comparison = new CamlComparisonExpression(SPQueryNodeType.LessThanOrEqual, Visit(node.Arguments[0]), Visit(node.Arguments[1]), (bool)((ConstantExpression)node.Arguments[2]).Value); break; case "QueryGeq": comparison = new CamlComparisonExpression(SPQueryNodeType.GreaterThanOrEqual, Visit(node.Arguments[0]), Visit(node.Arguments[1]), (bool)((ConstantExpression)node.Arguments[2]).Value); break; default: throw new NotSupportedException(); } _withinExpression = false; return(comparison); }
public virtual Expression VisitCamlComparison(CamlComparisonExpression node) { string[] parts = SPQueryNodeTypeMapping[node.SPNodeType].Split('|'); string comparison = parts[0]; CamlValueExpression valueExp; CamlFieldExpression fieldExp; if( node.Value is CamlValueExpression ) { valueExp = (CamlValueExpression)node.Value; fieldExp = (CamlFieldExpression)node.Field; } else { valueExp = (CamlValueExpression)node.Field; fieldExp = (CamlFieldExpression)node.Value; if( parts.Length > 1 ) comparison = parts[1]; } _whereXml.AppendFormat("<{0}>", comparison); _whereXml.AppendFormat("<FieldRef Name='{0}'/>", fieldExp.Name); _whereXml.AppendFormat("<Value Type='{0}'{1}>{2}</Value>", fieldExp.FieldType.ToString(), node.IncludeTimeValue ? " IncludeTimeValue='TRUE'" : string.Empty, valueExp.ValueString); _whereXml.AppendFormat("</{0}>", comparison); return node; }