Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Situation in a VS2010/SP2010 site:
List A with main items
List B with subitems, having a lookup column that points to List A ID
There are about 200 subitems for each item

The Page where users edit info regarding a main item (several fields) also allows users to change info regarding any of the 200 subitems (just a value), delete any of them or add new ones (there will be very few deletions or insertions).

When users click a button to save changes, main item is updated. At this moment each of the 200 subitems might also need updating.

So what's best approach?
- Delete the 200 old items by lookup id and re-insert the 200 new having the new values?

var query = from SPListItem item in listSubItems.Items
where (item["idLookup"].ToString() == id_Lookup)
    select item;
while (query.Count() > 0)
{
    query.First().Delete();
}

String[,] array_itemID_itemValue = ...;
for (int i = 0, i < 200, i++ )
{
    SPListItem item = listSubItems.AddItem();
    item["idLookup"] = id_Lookup;
    item["idSubItem"] = array_itemID_itemValue[i,0];
    item["valueColumn"] = array_itemID_itemValue[i,1];
    item.Update();
}
  • Or else, instead of deleting and then re-inserting, do all the necessary updates inside of the while (query.Count() > 0) cycle, by searching the array_itemID_itemValue for each item on the subItems list, deleting those which are not in the array. Then add the new items from the array.
  • Or some other approach/way...

  • If 1st approach is best, is there no way to bulk delete?

share|improve this question

closed as too localized by SPDoctor Jun 24 '13 at 14:47

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

You can consider the below link if you decided to use the bulk delete, well this can still be useful for bulk update

SPWeb.ProcessBatchData

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.