Trying to figure out how to update the following code to get paginated results by passing 'page' and 'pageSize':
using (ClientContext spClientContext = new AuthenticationManager().GetACSAppOnlyContext(siteUrl, _clientId, _clientSecret))
{
if (spClientContext != null)
{
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View Scope="RecursiveAll">" +
"<Query>" +
"<Where>" +
"<Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq>" +
"</Where>" +
"<OrderBy><FieldRef Name=\"FileLeafRef\" Ascending=\"FALSE\"/></OrderBy>" +
"</Query>" +
"<RowLimit>10</RowLimit>" +
"</View>";
List list = spClientContext.Web.Lists.GetByTitle("Documents");
ListItemCollection listItems = list.GetItems(camlQuery);
spClientContext.Load(listItems,
items => items.Include(
item => item.DisplayName,
item => item.FileSystemObjectType,
item => item.File,
item => item.File.Name,
item => item.File.Author,
item => item.File.ModifiedBy,
item => item.File.ListItemAllFields["Created"],
item => item.File.ListItemAllFields["Modified"],
item => item.File.ListItemAllFields["FileRef"],
item => item.File.Length));
spClientContext.ExecuteQuery();
if (listItems != null && listItems.Count > 0)
{
foreach (ListItem item in listItems)
{
if (item.FileSystemObjectType.Equals(FileSystemObjectType.File))
{
// Do Stuff
}
}
}
}
}
The code above would be included in a method where 'pageSize' would get passed to the CAML Query 'RowLimit' element value. That is working. I am fairly new to SharePoint CSOM dev so trying to figure out now how to set page or position so I can query only paginated results on request? Thanks for the help!