public List<Entity> GetEntities()
{
int queryCount = 5000;
int pageNumber = 1;
QueryExpression contactQuery = new QueryExpression("contact")
{
Distinct = false,
NoLock = true,
ColumnSet = new ColumnSet(new string[] { "fullname" }),
Criteria = new FilterExpression()
};
contactQuery.PageInfo = new PagingInfo
{
Count = queryCount,
PageNumber = pageNumber,
PagingCookie = null
};
contactQuery.Criteria.AddCondition("statecode", ConditionOperator.Equal, 0);
IEnumerable<Entity> entities = new List<Entity>();
while (true)
{
EntityCollection collection = service.RetrieveMultiple(contactQuery);
if (collection.Entities != null && collection.Entities.Count > 0)
{
entities = entities.Concat(collection.Entities.ToList());
}
if (collection.MoreRecords)
{
contactQuery.PageInfo.PageNumber++;
contactQuery.PageInfo.PagingCookie = collection.PagingCookie;
}
else
{
break;
}
}
return entities.ToList();
}
Dynamics CRM 组织服务查询超过5000条
最新推荐文章于 2024-02-04 18:52:31 发布
关键词由CSDN通过智能技术生成