Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an Microsoft Office 2010 AddIn which imports Data into SharePoint. The tool creates a Dictionary with over 5000 Values. Every Value is a C#-Class with Data and represents a SharePoint List Item. Because there are lookup relationships between almost all Dictionary-Values (ListItems) i use two loops:

  • in the first loop I create the ListItems and write back the generated ListItemIDs into the Dictionary
  • in the second loop I already have IDs for all ListItems and update the Lookups for all theese created ListItems

Is there a way to minimize the number of my queries ( in worst case scenario there are 5000 ExecuteQuery() for the first loop + 5000 for the second).

share|improve this question

2 Answers 2

A little-known and definitely under-used method is SPWeb.ProcessBatchData. Use this to really effectively perform operations in bulk - I still think there's a limit to what can be done at once, but depending on the schema of your lists this could still be the most efficient way (most definitely in terms of requests sent).

share|improve this answer
Thank you James, in this case, my code will run on the client side (MS Visio Client) and I think, I can't use Server Object Model. – user615993 Feb 26 '13 at 6:31
you people can transfer 500 data at a time since in caml query we have for operators it is limited to 500 rows – Venkatesh Kumar Balasubramani Jun 30 at 5:34

You do not need to perform ExecuteQuery() on every iteration of your loop, each server request can have a 2MB loadsize (depending on your setup). you can add something like this to your loop.

int counter = 0;
foreach(var item in ListItem)
   //do stuff

   if((counter%50) = 0)

This will send the past 50 updates to the server in one request which will help performance.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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