I have a document library which contain 6,000 ++ items, and i wrote the following code inside a remote event receiver to get the documents which are inside certain folder using FolderServerRelativeUrl
, as follow:
ListItemCollectionPosition position = null;
do
{
CamlQuery camlQuery6 = new CamlQuery();
camlQuery6.ViewXml = @"<View Scope='Recursive'><Query></Query><RowLimit>5000</RowLimit></View>";
//string.Format("<View Scope=\"RecursiveAll\"><Query><Where><Neq><FieldRef Name='ID' /><Value Type='Text'>{0}</Value></Neq></Where></Query><RowLimit>{1}</RowLimit></View>", "0", "3000");
camlQuery6.ListItemCollectionPosition = position;
camlQuery6.FolderServerRelativeUrl = context.Web.ServerRelativeUrl + "/ArchDocs/" + currentFilingSystemItem["DealName"].ToString();
ListItemCollection collListItem6 = context.Web.GetList(context.Web.ServerRelativeUrl + "/ArchDocs").GetItems(camlQuery6);
context.Load(collListItem6, items => items.Include(
item => item.Id,
item => item["FileDirRef"],
item => item["Title"],
), items => items.ListItemCollectionPosition);
context.ExecuteQuery();
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);
foreach (ListItem item in foundListItems)
{
}
but my above code will raise this error, although i am using paging which should allow me to query large document libraries :-
The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.
any advice on this please? Thanks