【发布时间】:2013-04-02 23:08:17
【问题描述】:
我有一个自定义应用程序,它使用 SharePoint 2010 来存储列表项并对这些项进行版本控制。搜索正在通过搜索服务进行,并且更新正在使用客户端对象模型成功。我们现在正尝试检索旧版本列表项的自定义属性以显示给用户,类似于 SharePoint 显示历史信息的方式,它在哪里提取文件版本,然后显示已更改属性的列表。
现在我们有以下内容,但该文件的版本没有显示任何可显示的属性,即使当我们在屏幕上查看历史记录时 SharePoint 确实显示了更改。
using (ClientContext context = new ClientContext(spURL)) {
Web site = context.Web;
context.Load(site);
context.ExecuteQuery();
File file = site.GetFileByServerRelativeUrl(sRelativeObjectPath);
context.Load(file);
context.ExecuteQuery();
FileVersionCollection versions = file.Versions;
context.Load(versions);
context.ExecuteQuery();
foreach (FileVersion ver in versions)
{
File verFile = site.GetFileByServerRelztiveUrl(ver.Url);
context.Load(verFile, f => f.ListItemAllFields);
//verFile.ListItemAllFields.FieldValues are null, need to get the properties of the ListItem
}
}
关于我应该如何提取版本的属性值有什么想法吗?这不在 SharePoint 中运行,因此我无权访问 SharePoint.dll 以使用 SPQuery 和 SPItem。
【问题讨论】:
-
看起来你只需要“context.ExecuteQuery();”在“context.Load(verFile, f => f.ListItemAllFields);”之后。
-
@vinny +1,我没有阅读完整的源代码……
标签: c# sharepoint sharepoint-2010 csom