Ques. I have this method wit return type as 'List Item Collection'and my list in SharePoint contains more than 5000 items. In order to overcome the threshold, I need to fetch items in batches by putting row limit but I do not know what to put in the place of ?? so that the return type is also 'ListItemCollection'(SharePoint Client Context). Please help
private static ListItemCollection GetItemsFromSharePointSiteList(string strListName, string strCamlQuery, ClientContext clientContext)
{
try
{
ListItemCollectionPosition itemPosition = null;
List listIPPMilestonesLE = clientContext.Web.Lists.GetByTitle(strListName);
CamlQuery query = new CamlQuery();
query.ViewXml = strCamlQuery;
query.DatesInUtc = false;
// ListItemCollection itemColl = new ListItemCollection();
do
{
Microsoft.SharePoint.Client.ListItemCollection listItemCollection = listIPPMilestonesLE.GetItems(query);
clientContext.Load(listItemCollection);
clientContext.ExecuteQuery();
foreach (ListItem oListItem in listItemCollection)
{
??
}
itemPosition = listItemCollection.ListItemCollectionPosition;
} while (itemPosition != null);
return null;
}
catch (Exception exc)
{
ErrorLog.Error(exc);
}
return null;
}