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

VB.NET中GraphServiceClient.Users.GetAsync的$select请求配置实现

VB.NET中使用GraphServiceClient通过$select获取用户属性

C# 实现示例

var result = await graphClient.Users["{user-id}"].GetAsync((requestConfiguration) =>
{
    requestConfiguration.QueryParameters.Select = new string []{ "displayName","givenName","postalCode","identities" };
});

VB.NET 对应实现

VB.NET中配置请求参数的Lambda写法与C#略有差异,你可以按以下方式补全代码:

Dim user = Await graphClient.Users(userUPN).GetAsync(
    Sub(requestConfiguration)
        requestConfiguration.QueryParameters.Select = { "displayName", "givenName", "postalCode", "identities" }
    End Sub
)

说明

  • VB.NET用Sub定义无返回值的Lambda表达式,对应C#中的匿名方法写法
  • 数组直接通过{}声明,无需额外指定new string []
  • 这段代码通过$select参数指定只获取用户的displayName、givenName、postalCode和identities属性,以此减少接口返回的数据量

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 04:00:58