从Client Objectmodel更新ListItem而不更改版本

时间:2011-07-04 09:28:10

标签: sharepoint-2010 sharepoint-clientobject

是否可以使用Sharepoint Client ObjectModel更新Created / Modified字段而无需更新版本?

var file = _ClientContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
_ClientContext.Load(file);
_ClientContext.ExecuteQuery();
ListItem listItem = file.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
MapMembers(listItem, info.MetaData);
listItem.Update();

listItem.SystemUpdate / Update(false)在Client ObjectModel中不可用。

由于

1 个答案:

答案 0 :(得分:7)

Microsoft.SharePoint.Client.File lp_newFile = lp_web.GetFileByServerRelativeUrl(lp_uri.LocalPath);
lp_context.Load(lp_newFile);
lp_context.ExecuteQuery();

//check out to make sure not to create multiple versions
lp_newFile.CheckOut();

ListItem lp_item = lp_newFile.ListItemAllFields;
listItem["Created"] = info.SourceFile.CreationTime;
listItem["Modified"] = info.SourceFile.LastWriteTime;
listItem.Update();

// use OverwriteCheckIn type to make sure not to create multiple versions 
lp_newFile.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);