//fetch数据想查询大于5000
public static void GetFetchAll(IOrganizationService organizationServiceProxy, ref EntityCollection entityCollection, string Fetch, int count = 5000, int page = 1)
{
//<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
string NewFetch;
string ReplaceStr = string.Format(@"<fetch page='{0}' count='{1}'", page, count);
NewFetch = Fetch.Replace("<fetch", ReplaceStr);
FetchExpression fetchExpression = new FetchExpression(NewFetch);
EntityCollection entityCollectionA = organizationServiceProxy.RetrieveMultiple(fetchExpression);
foreach (Entity item in entityCollectionA.Entities)
{
entityCollection.Entities.Add(item);
}
if (entityCollectionA.Entities.Count > 0)
{
GetFetchAll(organizationServiceProxy, ref entityCollection, Fetch, count, ++page);
}
}
dynamic fetch查询怎么查询超过5000条的数据
最新推荐文章于 2026-06-25 12:34:17 发布
这段代码展示了如何使用Fetch表达式进行分页查询大数据集。通过替换fetch查询中的页数和每页数量参数,实现了从OrganizationServiceProxy获取数据并递归加载剩余页面,直到所有数据都被加载到entityCollection中。
3255

被折叠的 条评论
为什么被折叠?



