SPSiteDataQuery query=new SPSiteDataQuery();
query.Query =@"<where/>";
query.Lists="Lists ServerTemplate='106'";//网站下所有的日历列表数据
query.ViewFields=@"<FieldRef Name='Title'/><FieldRef Name='EventDate'/><FieldRef Name='EndDate'/>";//查询条件
query.Webs="<Webs Scope='Recursive'/>";//
try{
using(SPSite site= new SPSite("http://"))
{
DataTable dt=site.RootWeb.GetSiteData(query);//查询的数据保存到
DataTable中
foreach(DataRow row in dt.Rows)
{
Console.WriteLine("dt["+column.ColumnName+"]:"+row[column]");
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex.StackTrace);
}