【问题标题】:fetchxml with group by return page cookies ="" and more recored =falsefetchxml with group by return page cookies="" 和更多记录 =false
【发布时间】:2026-02-10 18:30:01
【问题描述】:

当尝试使用 fetchxml 和 group by 进行分页时 总是 pagecookies 返回空字符串和更多记录返回 false

 string fetchXml = @" 
        <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'> 
            <entity name='appointment'> 
            <all-attributes />
               <attribute name='shiftstart' alias='shiftstartyear' groupby='true'  dategrouping='year' /> 
               <attribute name='shiftstart' alias='shiftstartmonth' groupby='true'  dategrouping='month' /> 
               <attribute name='shiftstart' alias='shiftstartday' groupby='true'  dategrouping='day' /> 
               <attribute name='contId' alias='contId' groupby='true' /> 
                  <filter type='and'>
                    <condition attribute ='status' operator='not-in'><value>2</value><value>3</value>
                    </condition>
                        <condition attribute ='contact' operator='eq' value ='" + contactId + @"' />
                    </filter>


                </entity> 
        </fetch>";
        string xml = CreateXml(fetchXml, PageCookies, pagenumber, pageSize);

        // Excute the fetch query and get the xml result.
        RetrieveMultipleRequest fetchRequest1 = new RetrieveMultipleRequest
        {
            Query = new FetchExpression(xml)
        };

        var returnCollection = ((RetrieveMultipleResponse)GlobalCode.Service.Execute(fetchRequest1)).EntityCollection;

【问题讨论】:

  • 这个问题不完整吗?我看不到你在哪里使用 PageCookiespagenumberpageSize

标签: c# dynamics-crm dynamics-crm-2016 fetchxml


【解决方案1】:

聚合查询可以返回的最大结果有一个限制 (50000)。

参考: Fetch XML report aggregate undocumented limit

因此,对聚合查询进行分页没有多大意义 - 即在考虑分页之前,您的查询将被修剪为 50k 个结果。

【讨论】: