"Unrecognized lambda expression." 使用 Microsoft.Graph 时
"Unrecognized lambda expression." when using Microsoft.Graph
我正在尝试从 Azure Active Directory 中提取用户数据。
我正在根据在以下位置找到的示例应用程序调整我的代码
https://github.com/microsoftgraph/msgraph-training-aspnetmvcapp/blob/main/Demos/03-add-msgraph/graph-tutorial/Helpers/GraphHelper.cs
我的函数目前看起来像:
Public Async Function GetUserDetailsAsync(ByVal accessToken As String) As Task(Of CachedUser)
Dim graphClient = New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
requestMessage.Headers.Authorization = New AuthenticationHeaderValue("Bearer", accessToken)
Return Task.FromResult(0)
End Function))
Dim user = Await graphClient.Me.Request().Select(Function(u) New With {u.DisplayName}).GetAsync()
Return New CachedUser With {
.Avatar = String.Empty,
.DisplayName = user.DisplayName,
.Email = If(String.IsNullOrEmpty(user.Mail), user.UserPrincipalName, user.Mail)
}
End Function
问题是它在 GetAsync()
的线路上卡住了。我收到消息 Unrecognized lambda expression. Parameter name: selectExpression
的异常
我应该怎么写Select?如果这是一个错误,有人有解决方法吗?
问题请参考以下代码
Dim graphClient = New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
requestMessage.Headers.Authorization = New AuthenticationHeaderValue("Bearer", accessToken)
Return Task.CompletedTask
End Function))
Dim user = Await graphClient.[Me].Request().[Select]("displayName").GetAsync()
Console.WriteLine(user.DisplayName)
我正在尝试从 Azure Active Directory 中提取用户数据。
我正在根据在以下位置找到的示例应用程序调整我的代码 https://github.com/microsoftgraph/msgraph-training-aspnetmvcapp/blob/main/Demos/03-add-msgraph/graph-tutorial/Helpers/GraphHelper.cs
我的函数目前看起来像:
Public Async Function GetUserDetailsAsync(ByVal accessToken As String) As Task(Of CachedUser)
Dim graphClient = New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
requestMessage.Headers.Authorization = New AuthenticationHeaderValue("Bearer", accessToken)
Return Task.FromResult(0)
End Function))
Dim user = Await graphClient.Me.Request().Select(Function(u) New With {u.DisplayName}).GetAsync()
Return New CachedUser With {
.Avatar = String.Empty,
.DisplayName = user.DisplayName,
.Email = If(String.IsNullOrEmpty(user.Mail), user.UserPrincipalName, user.Mail)
}
End Function
问题是它在 GetAsync()
的线路上卡住了。我收到消息 Unrecognized lambda expression. Parameter name: selectExpression
我应该怎么写Select?如果这是一个错误,有人有解决方法吗?
问题请参考以下代码
Dim graphClient = New GraphServiceClient(New DelegateAuthenticationProvider(Function(requestMessage)
requestMessage.Headers.Authorization = New AuthenticationHeaderValue("Bearer", accessToken)
Return Task.CompletedTask
End Function))
Dim user = Await graphClient.[Me].Request().[Select]("displayName").GetAsync()
Console.WriteLine(user.DisplayName)