Home > crosslistqueryinfo, SharePoint, spsitedataquery > SPSiteDataQuery & CrossListQueryInfo : Close siblings of SPQuery

SPSiteDataQuery & CrossListQueryInfo : Close siblings of SPQuery

Every SharePoint developer has sometime or the other uses SPQuery to query SharePoint list and document libraries, but there are some other methods which can be used to query data though lesser known

They are SPSiteDataQuery And CrossListQueryInfo

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 the Webs 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.

SPSiteDataQuery spSiteDataQuery = new SPSiteDataQuery();
spSiteDataQuery.Lists = "";
spSiteDataQuery.ViewFields = "";
spSiteDataQuery.Webs = "";
DataTable results = SPContext.Current.Web.GetSiteData(spSiteDataQuery);

The CrossListQueryInfo object uses the CrossListQueryInfo object to get the cached results or, if there are no cached results available, it performs a cross-list query to the database and then caches the results for future use.

CrossListQueryInfo query = new CrossListQueryInfo(); 
query.Lists = "";
query.Webs = "";
query.Query = SomeValue";
query.ViewFields = """;
query.UseCache = true;
CrossListQueryCache cache = new CrossListQueryCache(query);
DataTable results = cache.GetSiteData(SPContext.Current.Site);
  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 )

Connecting to %s

%d bloggers like this: