Sharepoint CSOM版本冲突

时间:2019-04-17 08:59:34

标签: c# sharepoint csom

目前,我正在尝试弄清是什么原因导致以下行产生版本冲突。我已经完成了研究,但是我的很多搜索似乎都指向缓存问题。但是我想具体知道哪个fieldValues与上一个调用冲突。谢谢。

ListItemCreationInformation listItemCreationInfo = new ListItemCreationInformation();
ListItem oListItem = list.AddItem(listItemCreationInfo);
oListItem["Title"] = "HelloFromCode";
oListItem.Update();
context.ExecuteQuery();

string filePath = @"";
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
MemoryStream ms = new MemoryStream();
fs.CopyTo(ms);
AttachmentCreationInformation newFile = new AttachmentCreationInformation { ContentStream = ms, FileName = "Test.docx" };

oListItem.AttachmentFiles.Add(newFile);
oListItem.Update();
context.ExecuteQuery();

现在,如果我尝试更改标题,而不是将文件附加到该项目,那么它将起作用。

oListItem["Title"] = "HelloFromCode2";
oListItem.Update();
context.ExecuteQuery();

如果再次更改名称会导致版本冲突,这确实有点道理,但可以。因为我不太了解版本冲突的根本原因,所以会造成混乱。

如果我删除了第一个context.ExecuteQuery(),它就可以工作了(这确实有意义,因为在执行之前没有任何更改)。

再次感谢。

0 个答案:

没有答案
相关问题