访问SharePoint 2010 ListItem中的属性以获取版本历史记录

时间:2013-04-02 14:50:36

标签: c# sharepoint sharepoint-2010 csom

我有一个自定义应用程序,它使用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。

1 个答案:

答案 0 :(得分:1)

File课程中有File.ListItemAllFields property,您可以使用相关的列表项及其字段。

相关问题