[英]Is there a way how to get total count of entities of given type in CRM without paging
Suppose I have query like 假设我有类似的查询
var countAlias = "entity_count";
var query = FormattableString.Invariant($@"
<fetch distinct='false' aggregate='true'>
<entity name='{entityName}'>
<attribute name='createdon' alias='{countAlias}' aggregate='count'/>
</entity>
</fetch>");
var response = organizationService.RetrieveMultiple(new FetchExpression(query));
var entity = response.Entities.First();
var count = (int)((AliasedValue)entity[countAlias]).Value;
This works nicely unless there is more than 50K records - then it hits the aggregation limit. 除非有超过5万条记录,否则此方法效果很好-则达到了聚合限制。 Is there a way how to query total count of entities in system without paging ?
有没有一种方法可以不分页地查询系统中实体的总数?
Unfortunately, short answer is No . 不幸的是,简短的回答是“ 否” 。
Fetchxml is the only option to do aggregation like count, sum, etc - that too has 50k record limit due to performance consideration (upper limit can be bent for on-prem). Fetchxml是进行聚合(如计数,总和等)的唯一选项-由于性能方面的考虑 ,该记录也具有50k的记录限制(上限可以针对本地部署进行调整)。
Query expression, LINQ to CRM doesn't support aggregation. 查询表达式,LINQ to CRM 不支持聚合。 That's why we got paging cookie as a choice from MS to iterate & count the records.
这就是为什么我们可以从MS中选择分页cookie来迭代和计数记录。
Alternatively, (unlikely) if you have reporting replication sql DB by pushing a data sync, Rollup count can be done with some jobs in timely manner. 或者,(不太可能)如果您通过推送数据同步来报告复制sql DB,则可以通过某些作业及时完成汇总计数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.