I facing a problem while retrieving the list data from SharePoint online. I have list items around 20,000. I am using a caml query to retrieve the data based on conditions in dotnet csom. it has 5300 items however I am getting complete 20,000 items see the below code. I have used below logic to over come the list view threshold limit.
var list = web.Lists.GetByTitle("ListName");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><RowLimit>3000</RowLimit><Where><Or><Eq><FieldRef Name='AccountRecordType' /><Value Type='Text'>Institution</Value></Eq><And><Eq><FieldRef Name='AccountRecordType' /><Value Type='Text'>Group</Value></Eq><Neq><FieldRef Name='MemberStatus' /><Value Type='Text'>Member</Value></Neq></And></Or></Where></View>";
List<ListItem> lstListItemCollection = new List<ListItem>();
do
{
ListItemCollection listItemCollection = list.GetItems(camlQuery);
clientContext.Load(listItemCollection);
clientContext.ExecuteQuery();
//Adding the current set of ListItems in our single buffer
lstListItemCollection.AddRange(listItemCollection);
//Reset the current pagination info
camlQuery.ListItemCollectionPosition = listItemCollection.ListItemCollectionPosition;
} while (camlQuery.ListItemCollectionPosition != null);
foreach (ListItem listItem in lstListItemCollection)
{
}