Thursday, 6 March 2014

SharePoint get data from all document libraries using SPSiteDataQuery

SharePoint get data from all document libraries using SPSiteDataQuery
SPSiteDataQuery query = new SPSiteDataQuery();
query.Lists = "<Lists ServerTemplate='101' />";
query.Query = "<OrderBy>" +  "<FieldRef Name=\"Title\" />" +  "</OrderBy>";
query.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Validated' /><FieldRef Name='ContentType' /><FieldRef Name='FileRef' />";
query.Webs = "<Webs Scope='SiteCollection' />";
DataTable dt= site.RootWeb.GetSiteData(query);