Destination:\ SharePoint > Destination:\ SharePoint 2013 > Posts > Query multiple lists across sites in a web site collection
September 12
Query multiple lists across sites in a web site collection
Title: Query multiple lists across sites in a web site collection

Details: SPSiteDataQuery Class - This is one of the very intresting and wonderful classes available in SharePoint to retreive information from list across sites in the same web site collections. How many of you have tried the roll up ( not including the CQWP ) by coding? Look at the below code and see the simplicity of it. Simply build the SPSiteDataQuery ( query ) to the GetSiteData Method and get DataTable in return. One important thing to notice is that, it is not supported in SharePoint 2010 Sandboxed Solutions.

Code:

void UsingSPSiteDataQuery(SPWeb web)
{
SPSiteDataQuery query = new SPSiteDataQuery();

query.Lists = "";
query.ViewFields = "";
query.Webs = "";

web.GetSiteData(query);
}

Comments

Query multiple lists across sites in a web site collection

Post migrated by Metalogix - The SharePoint Management Experts
www.metalogix.net
9/11/2010 2:42:43 PM
 Commented by Metalogix Software Corp. on 9/11/2010 2:42:43 PM

Srini SistlaNo presence information on 9/11/2010 1:48 PM

List Query to Multiple Site Collection

hi srirni....

great post ...



is there any way to Query data from multiple site collections other than FullTextSQLQuery
 on 3/29/2011 1:36 AM