I have followed the msdn sample of how to use paging while retrieving items from a list. Here is my code:
internal static void ReturnAllFiles(ClientContext context)
{
List list = context.Web.Lists.GetByTitle(Globals.DocLibName);
context.Load(list);
ListItemCollectionPosition itemPosition = null;
while (true)
{
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml = "<View><ViewFields>" +
"<FieldRef Name='Title'/>" +
"</ViewFields><RowLimit>5</RowLimit></View>";
ListItemCollection collListItem = list.GetItems(camlQuery);
context.Load(collListItem);
context.ExecuteQuery();
itemPosition = collListItem.ListItemCollectionPosition;
foreach (ListItem oListItem in collListItem)
{
Console.WriteLine("Title: {0}: \nBody: {1}", oListItem["Title"], oListItem["Body"]);
}
if (itemPosition == null)
{
break;
}
Console.WriteLine("\n" + itemPosition.PagingInfo + "\n");
}
However even though the <RowLimit>
attribute is present in my CamlQuery
, I still get the following error exception:
The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.
What am I doing wrong here?