gpt4 book ai didi

c# - 在执行 spsitedataquery 后获取项目来自的子站点

转载 作者:太空宇宙 更新时间:2023-11-03 22:02:28 24 4
gpt4 key购买 nike

我有以下代码:

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.

关于c# - 在执行 spsitedataquery 后获取项目来自的子站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9626000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com