CAML查询仅选择顶级文件夹

Zee*_*e99 5 c# sharepoint caml sharepoint-2010

我想使用CrossListQueryCache选择文档库的文件夹列表(没有子文件夹,而不是递归).

一切都工作正常,除了我收到列表中的所有文件夹和子文件夹,而不仅仅是第一级文件夹.我需要在下面的代码中进行更改,以便只返回第一级文件夹,而不返回其子文件夹和子子文件夹等...

string query = string.Empty;
string websQuery = string.Format("<Webs Scope=\"{0}\"/>", "None");
string lists = "<Lists ServerTemplate=\"101\"" + " ><List ID=\"" + listid + "\" /></Lists>";  
bool useList = true;
string relativeUrl = this.GetRelativeUrl();
query = string.Format("<Where><Eq><FieldRef Name='FSObjType' /><Value Type='LookUp'>1</Value></Eq></Where>", relativeUrl); 

CrossListQueryInfo info = new CrossListQueryInfo();
info.Lists = lists;
info.Webs = websQuery;
info.Query = query;
info.ViewFields = "<FieldRef Name=\"FileLeafRef\"/>";
info.WebUrl = web.ServerRelativeUrl;
CrossListQueryCache cache = new CrossListQueryCache(info);
SiteDataResults sd = cache.GetSiteDataResults(site, true);
Run Code Online (Sandbox Code Playgroud)

Mar*_*ski 1

使用 SPQuery.ViewAttributes 的“范围”与“递归”不同:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewattributes.aspx

如果您只想显示文件夹或不显示文件夹,那么您可以添加有关 ContentType 的信息,如下所示(Drax 的回答):
CAML 查询:如何从结果集中过滤文件夹?