title: Get SharePoint List in batches c# CSOM
body: <p>Can you help me getting the items of a SharePoint library (it is a library with document sets) using CSOM.
  The library has a lot more than 5000 items and I know SharePoint has a limit of 5000, so I am trying to get them in batches of 500. Is it possible?</p>
  
  <pre><code>clientContext.Credentials = new SharePointOnlineCredentials(username, securePassword);
  List oList = clientContext.Web.Lists.GetByTitle(libraryName);
  clientContext.Load(oList);
  clientContext.ExecuteQuery();
  CamlQuery query = new CamlQuery();
  query.ViewXml = "&lt;View&gt;&lt;RowLimit&gt;500&lt;/RowLimit&gt;&lt;/View&gt;";
  ListItemCollection allDocumentSet = oList.GetItems(query);
  clientContext.Load(allDocumentSet);
  clientContext.ExecuteQuery();
  </code></pre>
  
  <p>I do not know why is not working. I get the following error.</p>
  
  <p>Microsoft.SharePoint.Client.ServerException: 'The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.'</p>
  
  <p>Why do I get the error if I am getting only 500 items per batch?</p>
  
  <p>Also, one additional question. When should I use "ExecuteQuery" and Load function?</p>
  
  <p>Thanks!</p>