Here is how to approach this:
QueryExpression query = new QueryExpression("lead");
query.ColumnSet.AddColumns(leadColumnSet);
int pageNumber = 1;
RetrieveMultipleRequest multiRequest;
RetrieveMultipleResponse multiResponse;
do
{
query.PageInfo.Count = 5000;
query.PageInfo.PagingCookie = (pageNumber == 1) ? null : multiResponse.EntityCollection.PagingCookie;
query.PageInfo.PageNumber = pageNumber++;
multiRequest = new RetrieveMultipleRequest();
multiRequest.Query = query;
multiResponse = (RetrieveMultipleResponse)ServiceProxy.Execute(multiRequest);
leads.Entities.AddRange(multiResponse.EntityCollection.Entities);
} while (multiResponse.EntityCollection.MoreRecords);
Thanks, recommended generic code. Helped me!
ReplyDeleteAJ Sterman
Thanks for code...Its really helpfull to me.
ReplyDelete