Client Object Model Access Large Lists/Overcome ListView Threshold while accessing large list

If you want retrieve large list using Client Object Model. You can use the ListItemCollectionPosition class to implement paging list item retrieval according to the position of items relative to their collection. Use the RowLimit element to specify the number of items to return per page.It is very useful when list view threshhold limit is reached.

static void Main(string[] args)
{
ClientContext clientContext = new ClientContext(“http://testLink”);

List list = clientContext.Web.Lists.GetByTitle(“Tasks”);

ListItemCollectionPosition itemPosition = null;
while (true)
{
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml = @”<View>
<ViewFields>
<FieldRef Name=’Title’/>
</ViewFields>
<RowLimit>1</RowLimit>
</View>”;

ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();

itemPosition = listItems.ListItemCollectionPosition;

foreach (ListItem listItem in listItems)
Console.WriteLine(“Item Title: {0}”, listItem[“Title”]);

if (itemPosition == null)
break;

Console.WriteLine(itemPosition.PagingInfo);
Console.WriteLine();
}

Console.ReadLine();
}​