public static EntityCollection GetStringMapData(IOrganizationService service) { EntityCollection ec = new EntityCollection(); EntityCollection rs; int pageNum = 1; string pagingCookie = ""; do { if (pagingCookie != null && pagingCookie != "") { pagingCookie = pagingCookie.Replace("\"", "'").Replace(">", ">").Replace("<", "<"); } var fetchXml = CrmHelper.GetOptionFetch(pageNum, pagingCookie); rs = service.RetrieveMultiple(new FetchExpression(fetchXml)); ec.Entities.AddRange(rs.Entities); pagingCookie = rs.PagingCookie; pageNum++; }while (rs.MoreRecords && pageNum < 20); MessageBox.Show($"Last Page: {pageNum} Total number of records: {ec.Entities.Count}"); return(ec); }