gpt4 book ai didi

c#-4.0 - 使用客户端上下文和 CAML 查询删除共享点列表中的所有行

转载 作者:行者123 更新时间:2023-12-02 16:59:14 24 4
gpt4 key购买 nike

我是 SharePoint 新手,想要使用 C# ClientContext 类和 CAML 查询删除 SharePoint 列表中的所有行。

如何有效地实现它?

最佳答案

我解决了。我们了解到,我们需要以相反的顺序删除列表中的项目。

链接:http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollection.delete.aspx

ListItemCollection listItems = oList.GetItems(CamlQuery.CreateAllItemsQuery());
clientContext.Load(listItems,
eachItem => eachItem.Include(
item => item,
item => item["ID"]));
clientContext.ExecuteQuery();

var totalListItems = listItems.Count;
Console.WriteLine("Deletion in " + currentListName + "list:");
if (totalListItems > 0)
{
for (var counter = totalListItems - 1; counter > -1; counter--)
{
listItems[counter].DeleteObject();
clientContext.ExecuteQuery();
Console.WriteLine("Row: " + counter + " Item Deleted");
}
}

关于c#-4.0 - 使用客户端上下文和 CAML 查询删除共享点列表中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16014079/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com