Sample code to retrieve more than 5000 records using FetchXML in CRM

Originally posted on Nishant Rana's Weblog:
Hi, Sharing a sample code to retrieve more than 5000 records using the Fetch XML. Version 1 : private List<Entity> GetTotalRecordsfromFetch(string fetchXML, IOrganizationService orgService) { List<Entity> lstEntity = new List<Entity>(); int fetchCount = 5000; int pageNumber = 1; string pagingCookie = null; while (true) { // Build fetchXml…