Home > MOSS, SharePoint, spsitedataquery > SPSiteDataQuery : Query across multiple lists in multiple Web sites in SharePoint

SPSiteDataQuery : Query across multiple lists in multiple Web sites in SharePoint


SPSiteDataQuery can be used to query across multiple lists in multiple Web sites in the same Web site collection.
You can use an instance of this class to retrieve data from selected lists or from all lists in the current site collection. Specify the scope of the query by setting theWebs property. Specify the lists to participate in the query by setting the Lists property and the fields to return by setting the ViewFields property. Control data selection and order by setting the Query property.
SPWeb web = SPContext.Current.Web;
SPSiteDataQuery query = new SPSiteDataQuery();

query.Lists = "";

query.ViewFields = "";

query.Query = "" +
"" +
"";

query.Webs = "";

DataTable dt = web.GetSiteData(query)
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: