I have the following CAML query to iterate over a large SharePoint document library :-
do
{
CamlQuery camlQuery6 = new CamlQuery();
// The RowLimit tells SharePoint to only scan the next 1000 items
camlQuery6.ViewXml = @"<View><ViewFields><FieldRef Name='Title'/></ViewFields><RowLimit>5000</RowLimit></View>";
// this tells SharePoint where to start, the first time through this loop
// 'position' will be null, so it will start at the beginning of the List
camlQuery.ListItemCollectionPosition = position;
ListItemCollection collListItem6 = context.Web.GetList(context.Web.ServerRelativeUrl + "/Library3").GetItems(camlQuery6);
context.Load(collListItem6, items => items.Include(
item => item.Id,
item => item["FileDirRef"],
item => item["Title"],
item => item["DealStage"],
item => item["DealName"],
item => item["Fund"]
));
context.ExecuteQuery();
// this line grabs the position from where SharePoint left off,
// so we can pass that in as the starting position the next time through the loop
position = collListItem6.ListItemCollectionPosition;
foreach (ListItem listItem in collListItem6) // collect the items we found in this chuck of searched items
{
foundListItems.Add(listItem);
}
}
while (position != null);
but on the context.ExecuteQuery();
i will get this error Value does not fall within the expected range