简体   繁体   English

有没有一种方法可以在不进行分页的情况下获取CRM中给定类型的实体的总数

[英]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.

相关问题 Dynamics CRM如何获取所有实体的列表 - Dynamics CRM how to get list of all entities 在分页之前计算记录的总大小并在分页后返回它们而不需要两次访问数据库 - Count total size of records before paging and return them after paging without hitting the database twice 当数据源是具有查询参数的域数据源并且还启用了分页时,如何获取网格视图的总行数? - How to get total rows count of grid view while data source is domain data source with query parameters and paging is also enabled? 如何对2个子实体进行分组并获得这两个子实体的总数? - How to group by on 2 child entities and get total of both this child entities? 非通用计数相关实体而不加载它们 - Count related entities without loading them, non-generic way 没有总行的SQL级别分页 - SQL level paging without total rows 在没有早期绑定实体的CRM中创建ActivityParty - Create ActivityParty in CRM without early bound Entities 如果您知道当前页面以及页面总数,如何像Google一样模仿页面? - If you know the current page, and total page count, how to mimick paging like google? 如何在MVC C#控制器的JSON服务侧面分页中包括总计数 - How to include total Count in JSON service Side Paging with MVC C# Controller 如何获得与给定实体关联的CRM角色 - How do i get CRM Roles associated to a given Entity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM