我有以下代码:
SPSiteDataQuery query = new SPSiteDataQuery();
//Get List query string
query.Lists = "<Lists BaseType='1'></Lists>";
query.ViewFields = "<FieldRef Name='Title' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='ContentTypeId' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='ContentType' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='ArticleStartDate' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='Synopsis' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='PublishingRollupImage' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='Location' Nullable='TRUE' />";
query.ViewFields += "<FieldRef Name='LOBGroup' Nullable='TRUE' />";
query.Query = "<Where>" +
"<Contains>" +
"<FieldRef Name='ContentType'/>" +
"<Value Type='Text'>DCP_Article</Value>" +
"</Contains>" +
"</Where>";
query.Query += "<OrderBy>" +
"<FieldRef Name='ArticleStartDate' Descending='TRUE' />" +
"</OrderBy>";
query.RowLimit = Convert.ToUInt32(loadsize);
query.Webs = "<Webs Scope='Recursive' />";
//Get Site Data from web
DataTable dt = web.GetSiteData(query);
在我的结果中,我想获得该项目来自的子站点,我知道如果我使用 query.ViewFields += "<FieldRef Name='FileRef' Nullable='TRUE' />";我可以获得该项目的完整网址,但无论如何我可以只获得它来自的子网站吗?是这样的: query.ViewFields += "<FieldRef Name='SiteName' Nullable='TRUE' />";
请您参考如下方法:
尝试:
query.ViewFields += "<ProjectProperty Name=\"Title\" />";
有关详细信息,请参阅 SPSiteDataQuery.ViewFields :
Site properties may be included by using the ProjectProperty tag. The Name attribute of the ProjectProperty tag identifies the specific property and may contain one of the following values:
Title -- the title of the Web site that contains the item.
WebId -- the GUID of the Web site that contains the item.
