Recently I need to take care an SP2010 farm which I am not familiar. There is an event receiver with part of code as below:
SPListItemCollection ListA = properties.Web.Lists["ListA"].Items;
List<int> idList = new List<int>();
foreach (SPListItem item in ListA)
{
if (Convert.ToString(item["Title"]) == variableA)
{
idList.Add(item.ID);
}
}
foreach (int i in idList)
{
properties.Web.Lists["listA"].Items.DeleteItemById(i);
}
The problem is right now the "ListA" consist more than 30,000 records and it takes 10 minutes to delete 100 items. Obviously we don't need to loop thru 30,000 records in "ListA".
I cannot find useful sample on web because our server have an old patch level (and we cannot patch for some reason). For example, "using Microsoft.SharePoint.Client.QueryExpression;" return "QueryExpression" not exist in namespace "Microsoft.SharePoint.Client".
Could you advice me how to rewrite with basic namespace like "Microsoft.SharePoint"?