实现 OR 后,CAML 查询失败



在我的 SharePointCAML查询中,使用一个输入进行筛选时,它是成功的。但是,当我添加<Or>以包含另一个输入时,它失败了。

以下是CAML查询。错误是由于多输入格式错误造成的吗?


单输入(通过(

<Where>
<And>
<Eq>
<FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>
</Eq>
<Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
</And>
</Where>

多路输入(失败(

<Where>
<And>
<Eq>
<Or>
<FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value>
<FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value>
</Or>
</Eq>
<Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
</And>
</Where>

错误:

一个或多个字段类型未正确安装。转到列表 "设置"页面以删除这些字段。在 Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx( 在 Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPPagePrevCallback, ISPDataCallback pFilterLinkCallback, ISPDataCallback pSchemaCallback, ISPDataCallback pRowCountCallback, Boolean& pbMaximalView( at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData(( at Microsoft.SharePoint.SPListItemCollection.get_Count((

CAML 查询存在问题。它应该像

<Where>
<And>
<Or>
<Eq> <FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value> </Eq>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value> </Eq>
</Or>
<Neq><FieldRef Name ="ContentType"/><Value Type="Text">"Document"</Value></Neq>
</And>
</Where>

最新更新