在我的项目中,我想用CSOM批量更新列表项。但是,我无法发现任何相关信息。在我的搜索中,我发现SSOM不是CSOM。
StringBuilder methodBuilder = new StringBuilder();
string batch = string.Empty;
string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Batch OnError=\"Return\">{0}</Batch>";
string methodFormat = "<Method ID=\"{0}\">" +
"<SetList>{1}</SetList>" +
"<SetVar Name=\"Cmd\">Save</SetVar>" +
"<SetVar Name=\"ID\">{2}</SetVar>" +
"<SetVar Name=\"urn:schemas-microsoft-com:office:office#InstitutionType\">{3}</SetVar>" +
"</Method>";
SPList list = spWeb.Lists.TryGetList("Clients");
SPQuery query = new SPQuery();
query.Query = "<View/>";
SPListItemCollection listItem = list.GetItems(query);
foreach (SPListItem item in listItem)
{
methodBuilder.AppendFormat(methodFormat, item.ID, list.ID, item.ID, "None");
}
batch = string.Format(batchFormat, methodBuilder.ToString());
string batchReturn = spWeb.ProcessBatchData(batch);