需求: 查询整个网站七天内所有的内容更新
SPSiteDataQuery query1 = new SPSiteDataQuery(); query1.ViewFields = "<OrderBy><FieldRef Name=\"Modified\" Ascending=\"False\" /></OrderBy><Where><Gt><FieldRef Name=‘Modified‘ /><Value Type=‘DateTime‘><Today OffsetDays=‘-7‘ /></Value></Gt></Where>"; query1.RowLimit = 100; query1.Webs = "<Webs Scope=\"Recursive\" />"; query1.Lists = "<Lists BaseType=\"0\" />"; using (SPSite site = new SPSite("http://dev-sp")) { DataTable dt = site.RootWeb.GetSiteData(query1); foreach (DataRow row in dt.Rows) { foreach (DataColumn column in dt.Columns) { Console.WriteLine("dt[" + column.ColumnName + "]: " + row[column]); } } }