CAML查询SharePoint 2013

时间:2016-08-24 22:55:44

标签: sharepoint caml

您好我正在尝试为以下语句编写一个caml查询查询

(City =" A" || FirstName =" A" || LastName =" A")&& (color =" red" || color =" green" || color =" blue" || color =" violet")

这是我写的CAMl查询,但它不能正常工作

<Query><Where><And><Or><Contains><FieldRef Name='City' /><Value Type='Text'>A</Value></Contains><Or><Contains><FieldRef Name='FirstName' /><Value Type='Text'>A</Value></Contains><Contains><FieldRef Name='LastName' /><Value Type='Text'>A</Value></Contains></Or></Or></And><And><Or><Contains><FieldRef Name='Color' /><Value Type='Text'>Red</Value></Contains><Or>

GreenBlueViolet

2 个答案:

答案 0 :(得分:0)

我认为您添加了一个不完整的CAML查询,您需要的确切查询是:

<Query><Where><And><Or><Contains><FieldRef Name='City' /><Value Type='Text'>A</Value></Contains><Or><Contains><FieldRef Name='FirstName' /><Value Type='Text'>A</Value></Contains><Contains><FieldRef Name='LastName' /><Value Type='Text'>A</Value></Contains></Or></Or><Or><Contains><FieldRef Name='Color' /><Value Type='Text'>red</Value></Contains><Or><Contains><FieldRef Name='Color' /><Value Type='Text'>green</Value></Contains><Or><Contains><FieldRef Name='Color' /><Value Type='Text'>blue</Value></Contains><Contains><FieldRef Name='Color' /><Value Type='Text'>violet</Value></Contains></Or></Or></Or></And></Where></Query>

试试这个并告诉我。

答案 1 :(得分:0)

请尝试使用以下查询,它可能对您有帮助。

&#13;
&#13;
<Query>
<Where>
    <And>
        <Or>
            <eq><FieldRef Name='City' /><Value Type='Text'>A</Value></eq>
            <OR>
                <eq><FieldRef Name='FirstName' /><Value Type='Text'>A</Value></eq>
                <OR>
                    <eq><FieldRef Name='LastName' /><Value Type='Text'>A</Value></eq>
                </OR>
            </OR>
        </Or>

        <Or>
            <In>
                <FieldRef Name="color" />
                <Values>
                    <Value Type='Text'>red</Value>
                    <Value Type='Text'>green</Value>
                    <Value Type='Text'>blue</Value>
                </Values>
            </In>
        </Or>
    </And>
</Where>
</Query>
&#13;
&#13;
&#13;