![](/img/trans.png)
[英]SharePoint 2013 On Premise C# ClientContext Caml Query not filtering results
[英]SharePoint CAML query Where clause Not Filtering
我正在尝试为 SP2019 站点上的列表项构建 CAML 查询。 我有下面的代码返回整个列表。 我读到如果查询中有问题,则返回列表中的所有项目。 请指教。
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"]);
}
你有没有尝试过 -
camlQuery.ViewXml = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name = 'Title'/><Value Type ='Text'>" + searchfor+ "</Value></Eq></Where></Query></View>";
注意 - 如果列表/库中有文件夹,请使用 scope = RecursiveAll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.