示例#1
0
        public List <Entity> GetDataFromCrm(string fetchXml)
        {
            var ec = new List <Entity>();

            var    fetchCount   = 5000;
            var    pageNumber   = 1;
            string pagingCookie = null;

            while (true)
            {
                var xml = XmlParser.CreateXml(fetchXml, pagingCookie, pageNumber, fetchCount);

                var retrieved = Service.RetrieveMultiple(new FetchExpression(xml));
                ec.AddRange(retrieved.Entities);

                if (retrieved.MoreRecords)
                {
                    pageNumber++;
                    pagingCookie = retrieved.PagingCookie;
                }
                else
                {
                    break;
                }
            }

            return(ec);
        }