以下のコードを使用してSharePointリストアイテムをバッチ更新しており、バッチ更新を使用してアイテムのコンテンツタイプも更新できるかどうかを確認しようとしています。これはSharepoint2010用であり、Webサービスのみを使用できます。私はどこにも例を見つけることができませんでした。
public static void UpdateListItems(string SiteURL, string ListName, int[] ItemIDs, List<string> FieldNames, List<object> Values)
{
using (ListsSoapClient ls = GetListSoapClient(SiteURL))
{
XDocument xDoc = new XDocument(new XElement("Batch"));
xDoc.Root.Add(new XAttribute("OnError", "Continue"));
xDoc.Root.Add(new XAttribute("PreCalc", "TRUE"));
int ID = 0;
for (int i = 0; i < ItemIDs.Count(); i++)
{
ID++;
XElement xMethod = new XElement("Method",
new XAttribute("ID", ID),
new XAttribute("Cmd", "Update"),
new XElement("Field",
new XAttribute("Name", "ID"),
ItemIDs[i]
)
);
for (int j = 0; j < FieldNames.Count(); j++)
{
xMethod.Add(new XElement("Field",
new XAttribute("Name", Functions.SPFieldName(FieldNames[j])),
Values[j]
)
);
}
xDoc.Root.Add(xMethod);
}
ls.UpdateListItems(ListName, xDoc.Root);
}
}