简体   繁体   English

CAML查询以从文档库和页面库检索文件

[英]CAML query to retrieve files from Document libraries and Page Library

I am trying to search in Pages and Document libraries once. 我试图一次在页面和文档库中搜索。 Is there a template in CAML that works for both document libraries and pages libraries. CAML中是否有可同时用于文档库和页面库的模板。

I have this for pages library only but it doesn't search document libraries 我只有页面库有此文件,但不搜索文档库

siteDataQuery.Lists ="<listsLists ServerTemplate=\"850\" />"; 

Full Code 完整代码

 sing (SPWeb web = new SPSite(SPContext.Current.Site.RootWeb.Url).OpenWeb())
                {

                    siteDataQuery.ViewFields = "<FieldRef  Nullable=\"TRUE\" Name=\"FileRef\"/><FieldRef Name=\"Title\"/>";
                    siteDataQuery.Lists = "<Lists ServerTemplate=\"101\" />";
                    siteDataQuery.RowLimit = 500;
                    siteDataQuery.Webs = "<Webs Scope=\"Recursive\"/>";

                    siteDataQuery.Query = "<Where><And><Eq><FieldRef Name='ContentType' /><Value Type='Computed'Page-Archive Item</Value></Eq><Eq><FieldRef Name='Metadata' LookupId='True' /><Value Type='Integer'>447</Value></Eq></And></Where>"

                    System.Data.DataTable dataTable =  web.GetSiteData(siteDataQuery);
                }

I need to search every subsites and their respective document and page libraries. 我需要搜索每个子站点及其各自的文档和页面库。

Any ideas?? 有任何想法吗??

Please use this for document library:- 请将此用于文档库:-

siteDataQuery.Lists ="< listsLists ServerTemplate=\"101\" />";

SharePoint Server Template Id for 的SharePoint Server模板ID

Page Library => 850 页面库=> 850

and for 和为

Document library => 101 文档库=> 101

try to use this siteDataQuery.Lists as below 尝试如下使用此siteDataQuery.Lists

siteDataQuery.Lists = "<Lists MaxListLimit=\"2\">" +
              "<List ID="+web.Lists.TryGetList("firstlistname").ID+" />" +
              "<List ID="+web.Lists.TryGetList("secondlistname").ID+" />" +             
           "</Lists>";

Hope this will help 希望这会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM