MS Graph API V1.0 中是否有字符串“contains”的过滤条件

All*_*ech 3 c# azure-active-directory microsoft-graph-api

我使用下面的代码来查找 Department 中的用户:

string searhString="IT Admin Onsite";

var departmentPeoples = await graphServiceClient.Users.Request().Filter($"department eq '{searchString}'").Select(u => new {
                        u.DisplayName,
                        u.MobilePhone,
                        u.BusinessPhones,
                        u.UserPrincipalName
                    }).GetAsync();
Run Code Online (Sandbox Code Playgroud)

但是,我想搜索包含的所有部门,因此我的搜索字符串将是

字符串 searchhString="管理员";

我尝试过startswith,但是只有当给定示例代码中我的searchString 是“IT”时,这才有效。如何完成这个任务?

请帮忙。

All*_* Wu 6

恐怕contains任何 Microsoft Graph 资源都不支持这一点。

请参阅此处的详细信息。

注意:Azure AD 资源不支持以下 $filter 运算符:ne、gt、ge、lt、le 和 not。目前,任何 Microsoft Graph 资源都不支持 contains 字符串运算符。

目前,您可以在 C# 代码中获取所有结果并通过部门进行筛选。