誰かが私がここで間違っていることを教えてもらえますか? リスト内のすべての行を削除するメソッドにリスト名を渡そうとしています:
public static void DeleteLastUpdate(Microsoft.SharePoint.Client.List oList)
{
using (var context = new ClientContext(FrontEndAppUrl))
{
var ss = new System.Security.SecureString();
Array.ForEach("hhh".ToCharArray(), (c) => { ss.AppendChar(c); });
context.Credentials = new SharePointOnlineCredentials("yyy", ss);
var web = context.Web;
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy></Query></View>";
ListItemCollection collListItem = oList.GetItems(camlQuery);
context.Load(collListItem);
context.ExecuteQuery();
foreach (ListItem oListItem in collListItem)
{
string i = oListItem["ID"].ToString(); ;
ListItem ListItemToDelete = oList.GetItemById(i);
ListItemToDelete.DeleteObject();
context.ExecuteQuery();
}
oList.Update();
}
}
public static void GetCountry()
{
using (var context = new ClientContext(FrontEndAppUrl))
{
Microsoft.SharePoint.Client.List oList_Country = context.Web.Lists.GetByTitle("LISTNAME");
DeleteLastUpdate(oList_Country);
}
}
私が得ているエラーは context.Load(collListItem); にあります。
オブジェクトは、オブジェクトに関連付けられているコンテキストとは異なるコンテキストで使用されています。他にどのようにリストの値を Delete() メソッドに渡すことができますか?