SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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 '15 at 5:34

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.