我有这个CAML查询
var query = new SPQuery
{
Query = string.Format(@"<Where>
<Or>
<Or>
<Or>
<Or>
<Contains>
<FieldRef Name='{7}' />
<Value Type='Text'>{3}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='{6}' />
<Value Type='Text'>{2}</Value>
</Contains>
</Or
<Contains>
<FieldRef Name='{5}' />
<Value Type='Text'>{1}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='{4}' />
<Value Type='Text'>{0}</Value>
</Contains>
</Or>
</Where>", "title", "adress", "zipcode", "city", "searchTitle", "searchAdress", "searchZipcode", "searchCity")
};
每次运行并尝试使用List.GetItems(query);
时都会抛出此错误:
One or more field types are not installed properly. Go to the list settings page to delete these fields.
BUT!如果我删除了所有<Or>
代码,并且不会抛出该错误,但我需要<Or>
代码才能确保获得所有匹配。
我已确保所有fieldrefs都匹配100%列的内部名称。
答案 0 :(得分:0)
你是否尝试过没有Contains 7/3元素的查询?这个是不需要的。
你/你的其中一个没有右括号<Value Type='Text'>{2}</Value></Contains></Or<Contains>
,这可能会导致错误。
答案 1 :(得分:0)
更正您的CAML
var query = new SPQuery
{
Query = string.Format(@"<Where>
<Or>
<Or>
<Or>
<Contains>
<FieldRef Name='{7}' />
<Value Type='Text'>{3}</Value>
</Contains>
<Contains>
<FieldRef Name='{6}' />
<Value Type='Text'>{2}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='{5}' />
<Value Type='Text'>{1}</Value>
</Contains>
</Or>
<Contains>
<FieldRef Name='{4}' />
<Value Type='Text'>{0}</Value>
</Contains>
</Or>
</Where>", "title", "adress", "zipcode", "city", "searchTitle", "searchAdress", "searchZipcode", "searchCity")
};