[英]SharePoint CAML query Where clause Not Filtering
I am trying to construct a CAML query for list item on SP2019 site.我正在尝试为 SP2019 站点上的列表项构建 CAML 查询。 I have the below code returning the entire list.
我有下面的代码返回整个列表。 I read that if there is a issue in the query, all the items in the list are returned.
我读到如果查询中有问题,则返回列表中的所有项目。 Please advise.
请指教。
List dashboardList = context.Web.Lists.GetByTitle("Dashboard");
CamlQuery camlQuery = new CamlQuery();
string searchfor = "CPPMC";
camlQuery.ViewXml = "<Query><Where><Eq><FieldRef Name = 'Title'/><Value Type ='Text'>" + searchfor+ "</Value></Eq></Where></Query>";
ListItemCollection listItems = dashboardList.GetItems(camlQuery);
context.Load(listItems);
context.ExecuteQuery();
foreach (ListItem item in listItems)
{
Console.WriteLine("{0},{1},{2}",item.Id,item["Title"], item["Processing_x0020_Date"]);
}
Have you tried -你有没有尝试过 -
camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name = 'Title'/><Value Type ='Text'>" + searchfor+ "</Value></Eq></Where></Query></View>";
Note - use scope = RecursiveAll if you have folders in the list/library注意 - 如果列表/库中有文件夹,请使用 scope = RecursiveAll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.