是否有任何方法可以从SharePoint 2010中删除列表/库中的项目,但不仅基于创建的日期(默认信息策略选项),还包括此列表中列值的组合。
谢谢
答案 0 :(得分:0)
您可以根据特定的列值删除项目:
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["List1"];
SPQuery query = new SPQuery();
// create query for example that Title=xyz & FirstName=abc
query.Query = "<Where><And><Eq><FieldRef Name='Title' /><Value Type='Text'>xyz</Value></Eq><Eq><FieldRef Name='FirstName' /><Value Type='Text'>abc</Value></Eq></And></Where>";
// get all items as per query which will going to be delete
SPListItemCollection listItems = list.GetItems(query);
int itemCount = list.ItemCount;
for (int k=0; k<itemCount; k++)
{
SPListItem item = listItems[k];
listItems.Delete(k);
}