Retrieving all the data from an entity RRS feed

  • Question

  • Hi,

    I'm trying to get all the data from an entity, say in lots of 5000 records at a time. I'm trying to do something like this in code (as a recursive method)...

     private int LoadData(string entityName, int pageNumber)
                QueryExpression expression = new QueryExpression()
                    EntityName = entityName,
                    PageInfo = new PagingInfo()
                        PageNumber = pageNumber,
                        Count = 1,
                        ReturnTotalRecordCount = true
                var entityCollection = connection.Connection.RetrieveMultiple(expression);
                totalRecordCount += entityCollection.TotalRecordCount;
                if (entityCollection.TotalRecordCountLimitExceeded)
                    LoadData(entityName, ++pageNumber);

                return totalRecordCount;

    thinking that when it gets to the last page, the TotalRecordCountLimitExceeded property will be false but i dont think this is the case.

    Any help appreciated



    Wednesday, November 21, 2012 12:38 PM


All replies