You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Microsoft Graph Beta SDK 5.x迁移:配置$expand与嵌套属性过滤

解决Microsoft Graph Beta SDK v5中$expand配置问题

在v5版本的Microsoft Graph SDK中,QueryParameters对象提供了Expand属性(字符串数组类型),可以用来配置$expand参数,包括带过滤条件的展开。

完整迁移代码示例

client
    .Users[userId]
    .CalendarView
    .GetAsync(cfg =>
    {
        cfg.QueryParameters.StartDateTime = from;
        cfg.QueryParameters.EndDateTime = to;
        cfg.QueryParameters.Filter = filterQuery;
        cfg.QueryParameters.Select = SelectQuery;
        // 配置带过滤的$expand
        cfg.QueryParameters.Expand = new[] { 
            "singleValueExtendedProperties($filter=id eq 'String {543ec2fa-e468-4b54-be8e-787c70d4a79f} Name ParentEventId')" 
        };
    })

关键说明

  • v5 SDK将原有的链式调用(Filter()/Expand()等)统一整合到GetAsync的配置委托中,Expand对应cfg.QueryParameters.Expand,接收字符串数组,支持多个展开项。
  • 对于需要在展开时附加过滤的场景,直接将带过滤条件的展开表达式作为字符串传入即可,格式和OData原生的$expand语法一致。
  • 你之前的请求无效是因为未展开singleValueExtendedProperties,嵌套属性的过滤需要先通过$expand加载对应集合,或者在$expand中直接附加过滤条件来精准获取目标属性。

内容的提问来源于stack exchange,提问作者aweis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 14:30:49