I have a list which contains more than 50K docs. So going with SP recommended approach I have used ListItemCollectionPosition to get items in batch of 2000, but the ListItemCollectionPosition always return null.

SPQuery currentQuery = new SPQuery();
  currentQuery.RowLimit = 2000;
     itemCollection= docLib.GetItems(currentQuery); //this statement return less than 2000 items even library have 50K docs
    //some more stuff

    currentQuery.ListItemCollectionPosition = itemCollection.ListItemCollectionPosition;

So could anyone help me out to know the cause of the problem.

  • 2
    Have you tried currentQuery.ViewAttributes = "Scope=\"RecursiveAll\""?; – eirikb Jan 13 '15 at 6:47

Try add currentQuery.ViewAttributes = "Scope='RecursiveAll'"; and currentQuery.Folder = docLib.RootFolder;

Also, try minimizing batch size to 100 initially to identify the root cause.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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