AggregateOn

AggregateOn 元素表示属性,该属性用于确定分组的 FindItem 结果集的分组项的顺序。

<AggregateOn>
   <FieldURI/>
</AggregateOn>
<AggregateOn>
   <IndexedFieldURI/>
</AggregateOn>
<AggregateOn>
   <ExtendedFieldURI/>
</AggregateOn>

AggregateOnType

属性和元素

下面各部分介绍了属性、子元素和父元素。

Attributes

属性 说明
Aggregate
指示由 FieldURI 元素标识的属性的最大或最小值,该元素用于对项目组进行排序。

以下是可能的值:

-最低
-最大

子元素

元素 说明
FieldURI
标识由 URI 频繁引用的属性。
IndexedFieldURI
标识词典中的各个成员。
ExtendedFieldURI
标识要获取、设置或创建的扩展 MAPI 属性。

父元素

元素 说明
GroupBy
指定 FindItem 查询的任意分组。
下面是此元素的 XPath 表达式: /FindItem/GroupBy

备注

FindItem 操作可以返回分组结果。 在分组结果中,对于给定分组属性具有相同值的所有项将收集在一起,并显示为该组的子级。 例如,如果按发件人分组,则根据发件人 A、发件人 B 等是否将所有电子邮件组织到单独的组中。 这些组是发件人组的子级。

发件人组中的每个组都包含项目集合,例如来自每个发件人的实际电子邮件。 可以使用 SortOrder 元素对组中的项进行排序。 但是,若要根据项的属性值对组进行排序,必须使用聚合。

使用聚合时,组的顺序基于组中项的特定属性。 使用聚合对组中的项进行排序时,必须标识对组进行排序所依据的代表性属性。 可以使用 AggregateOn 元素指定代表性属性。

标识代表性属性时, Aggregate 属性用于指示是根据所标识属性的最大值还是最小值对组进行排序。 如果 Aggregate 属性设置为 Maximum,则从 AggregateOn 属性的最大值开始对组进行排序。 如果 Aggregate 属性设置为 Minimum,则从 AggregateOn 属性的最小值开始对组进行排序。

例如,如果要发出 FindItem 分组查询,按发件人分组,但要对组进行排序,以便具有最新电子邮件的组位于顶部,则可以使用 Aggregate 属性 Maximum 按发件人分组和聚合收到的日期/时间。

描述此元素的架构位于正在运行 MicrosoftExchange Server 2007 的计算机(已安装客户端访问服务器角色)的 EWS 虚拟目录中。

示例

以下示例显示了分组的 FindItem 请求和响应。 该示例显示了返回按 ConversationTopic 属性分组的项的请求。 根据 DateTimeReceived 属性的最大值,按降序返回两个组 A 和 B。

<!-- EXAMPLE REQUEST -->
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types">
  <soap:Body>
    <FindItem xmlns="https://schemas.microsoft.com/exchange/services/2006/messages"
                xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types"
                Traversal="Shallow">
      <ItemShape>
        <t:BaseShape>IdOnly</t:BaseShape>
        <t:AdditionalProperties>
          <t:FieldURI FieldURI="message:ConversationTopic"/>
          <t:FieldURI FieldURI="item:DateTimeReceived"/>
        </t:AdditionalProperties>    
      </ItemShape>
      <IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="20" Offset="0"/>
      <GroupBy Order="Ascending">
        <t:FieldURI FieldURI="message:ConversationTopic"/>
        <t:AggregateOn Aggregate="Maximum">
          <t:FieldURI FieldURI="item:DateTimeReceived"/>
        </t:AggregateOn>
      </GroupBy>
      <ParentFolderIds>
        <t:DistinguishedFolderId Id="inbox"/>
      </ParentFolderIds>
    </FindItem>
  </soap:Body>
</soap:Envelope>
<!-- EXAMPLE RESPONSE -->
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header>
    <t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="652" MinorBuildNumber="0" 
                         xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" />
  </soap:Header>
  <soap:Body>
    <FindItemResponse xmlns:m="https://schemas.microsoft.com/exchange/services/2006/messages" 
                      xmlns:t="https://schemas.microsoft.com/exchange/services/2006/types" 
                      xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <m:ResponseMessages>
        <m:FindItemResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:RootFolder IndexedPagingOffset="8" TotalItemsInView="8" IncludesLastItemInRange="true">
            <t:Groups>
              <t:GroupedItems>
                <t:GroupIndex>B</t:GroupIndex>
                <t:Items>
                  <t:Message>
                    <t:ItemId Id="AQAnAH=" ChangeKey="CQAAABY" />
                    <t:DateTimeReceived>2006-09-14T23:59:18Z</t:DateTimeReceived>
                    <t:ConversationTopic>B</t:ConversationTopic>
                  </t:Message>
                  <t:Message>
                    <t:ItemId Id="AQAnAHR=" ChangeKey="CQAAAw" />
                    <t:DateTimeReceived>2006-09-15T00:00:24Z</t:DateTimeReceived>
                    <t:ConversationTopic>B</t:ConversationTopic>
                  </t:Message>
                  <t:Message>
                    <t:ItemId Id="AQAnA==" ChangeKey="CQAAJXT" />
                    <t:DateTimeReceived>2006-09-15T00:22:45Z</t:DateTimeReceived>
                    <t:ConversationTopic>B</t:ConversationTopic>
                  </t:Message>
                </t:Items>
              </t:GroupedItems>
              <t:GroupedItems>
                <t:GroupIndex>A</t:GroupIndex>
                <t:Items>
                  <t:Message>
                    <t:ItemId Id="AQAnAAA==" ChangeKey="CQCJNe" />
                    <t:DateTimeReceived>2006-09-14T23:56:12Z</t:DateTimeReceived>
                    <t:ConversationTopic>A</t:ConversationTopic>
                  </t:Message>
                  <t:Message>
                    <t:ItemId Id="AQWgAA==" ChangeKey="CQAACJV6" />
                    <t:DateTimeReceived>2006-09-14T23:57:33Z</t:DateTimeReceived>
                    <t:ConversationTopic>A</t:ConversationTopic>
                  </t:Message>
                  <t:Message>
                    <t:ItemId Id="AAAA==" ChangeKey="CQA6CJXw" />
                    <t:DateTimeReceived>2006-09-15T00:23:31Z</t:DateTimeReceived>
                    <t:ConversationTopic>A</t:ConversationTopic>
                  </t:Message>
                </t:Items>
              </t:GroupedItems>
            </t:Groups>
          </m:RootFolder>
        </m:FindItemResponseMessage>
      </m:ResponseMessages>
    </FindItemResponse>
  </soap:Body>
</soap:Envelope>

若要对组中的项进行排序,请使用 SortOrder 元素。

注意

项标识符和更改键已缩短,以保持可读性。

元素信息

元素 示例
命名空间
https://schemas.microsoft.com/exchange/services/2006/types
架构名称
类型架构
验证文件
Types.xsd
可以为空
False

另请参阅