Azure AD Graph 任何 $filter 语法

Azure AD Graph any $filter syntax

我不完全理解所提供示例中的 any 语法 here under the $filter documentation。我也找不到关于它的更多信息。

any is supported when querying multi-valued properties. For example: https://graph.windows.net/contoso.com/users?api-version=2013-11-08&$filter=userPrincipalName eq 'Mary@Contoso.com' or proxyAddresses/any(c:c eq 'smtp:Mary@Contoso.com')

c:c 部分是什么?好像是 lambda...

What is the c:c part? Seems like lambda...

是的,你是对的。我们可以从这个 tutorial

中获得有关 $filter Lambda 运算符的更多信息

OData defines two operators any and all that evaluate a Boolean expression on a collection. They can work on either collection properties or collection of entities.

根据UserEnity,我们可以知道proxyAddresses是Collection(Edm.String)。所以 any(c:c eq 'smtp:Mary@Contoso.com') 等于 User.proxyAddresses.Where(c=>c.equals("smtp:Mary@Contoso.com").

是的,你是对的。 c 是一个 lambda 变量, c eq 'smtp:Mary@Contoso.com' 是 lambda 表达式。

proxyAddresses/any(c:c eq 'smtp:Mary@Contoso.com') 将 return 的 proxyAddresses 集合,其 lambda 表达式 return 为真。

可以找到更多示例和解释 here