开发者

Can SPSiteDataQuery search both List and Libraries?

开发者 https://www.devze.com 2022-12-29 20:50 出处:网络
I have the following code: SPSiteDataQuery query = new SPSiteDataQuery(); query.ViewFields = \"<FieldRef Name=\\\"UniqueId\\\" />\";

I have the following code:

SPSiteDataQuery query = new SPSiteDataQuery();
query.ViewFields = "<FieldRef Name=\"UniqueId\" />";
query.Webs = "<Webs Scope=\"SiteCollection\" />";
query.Query = "<Where<Eq><FieldRef Name='MyCustomField' /><Value Type='Boolean'>1</Value></Eq></Where>";
query.Lists = "<Lists BaseType=\"1\" />";
DataTable results = site.开发者_开发百科RootWeb.GetSiteData(query);

This searches all the Document Libraries in the site collection, but I want to search all the Lists as well. Is there a way to set the Lists property to search both at the same time?


I don't believe there is.

SPSiteDataQuery targets 1 specific kind of content (i.e. list type) at a time.

When you need results from different kinds of content that, for instance, share a common custom field, create a managed property in Search (in the Shared Service Provider) and then use the FullTextSqlQuery class to query all content (which works cross site collection also, seeing as it is using the MOSS Search index).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号