在我的SharePoint CAML查询中,当使用两个输入进行筛选时,它是成功的。但是,当我有3个或更多时,它失败了。
使用两个以上的输入时,是否使用其他格式?
通过(2个字段):
<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>
失败(3个字段):
<Where>
<And>
<Or>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value></Eq>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value></Eq>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H3</Value></Eq>
</Or>
<Neq><FieldRef Name ="ContentType"/><Value Type="Text">Document</Value></Neq>
</And>
</Where>
错误:
无法完成此操作。请再试一遍。在Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)在Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClientpSqlClient,字符串bstrUrl,字符串bstrListName,字符串bstrViewName,字符串bstrViewXml,SAFEARRAYFLAGS fSafeArrayFlags,ISP2DSafeArrayWriter pSACallback,ISPDataCallback pPagingCallback,ISPDataCallback pPagingPrevCallback,ISPDataCallbackpFilterLinkCallback,ISPDataCallback pSchemaCallback,ISPDataCallbackpRowCountCallback,Boolean&pbMaximalView)Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()在Microsoft.SharePoint.SPListItemCollection.get_Count()
在CAML语法中,<Or>
和<And>
以及binary运算符。因此,它们必须仅具有两个操作数。如果需要更多,则必须相应地嵌套它们。您的情况:
<Where>
<And>
<Or>
<Or>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H1</Value></Eq>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H2</Value></Eq>
</Or>
<Eq><FieldRef Name="Header1Ref"/><Value Type="Text">H3</Value></Eq>
</Or>
<Neq><FieldRef Name ="ContentType"/><Value Type="Text">Document</Value></Neq>
</And>
</Where>