实施 OR 后 CAML 查询失败
CAML Query Failed After Implementing OR
在我的 SharePoint CAML
查询中,当使用一个输入进行过滤时,它是成功的。但是,当我添加 <Or>
以包含更多输入时,它失败了。
下面是 CAML
个查询。是不是Multiple Input的格式错误?
单输入(通过)
<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>
错误:
One or more field types are not installed properly. Go to the list
settings page to delete these fields. at
Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at
Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient
pSqlClient, String bstrUrl, String bstrListName, String bstrViewName,
String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags,
ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback,
ISPDataCallback pPagingPrevCallback, 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>
在我的 SharePoint CAML
查询中,当使用一个输入进行过滤时,它是成功的。但是,当我添加 <Or>
以包含更多输入时,它失败了。
下面是 CAML
个查询。是不是Multiple Input的格式错误?
单输入(通过)
<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>
错误:
One or more field types are not installed properly. Go to the list settings page to delete these fields. at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) at Microsoft.SharePoint.Library.SPRequest.GetListItemDataWithCallback2(IListItemSqlClient pSqlClient, String bstrUrl, String bstrListName, String bstrViewName, String bstrViewXml, SAFEARRAYFLAGS fSafeArrayFlags, ISP2DSafeArrayWriter pSACallback, ISPDataCallback pPagingCallback, ISPDataCallback pPagingPrevCallback, 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>