小编All*_*ech的帖子

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

我使用下面的代码来查找 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”时,这才有效。如何完成这个任务?

请帮忙。

c# azure-active-directory microsoft-graph-api

3
推荐指数
1
解决办法
6800
查看次数

如何使用 MS Graph API 获取组织中的所有部门

我使用下面的代码来查找部门名称:

GraphServiceClient graphServiceClient = connectToGraphAPI(Globals.adTenantId, Globals.adClientId, Globals.adClientSecret);

var Peoples = await graphServiceClient.Users[userid].People.Request().GetAsync();
foreach (Person People in Peoples) {
    if (People.DisplayName != null && People.DisplayName.Equals(userName)) {
        return People.Department.ToString();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,我想获取组织中所有部门的列表,而不是查找特定用户的部门。

c# azure-active-directory microsoft-graph-api

3
推荐指数
1
解决办法
2634
查看次数

将条件语句放在 C# 中的静态类中

我有以下课程:

public static class AllAcess
{
    public static int var1;

    //Some conditional statements
    if(somecondition)
    {
        var1 = x;
    }
    else
    {
        var1 = y;
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能在课堂上放一些条件语句。目前它不允许 if ,else 等。

请建议可以在此处用作条件的逻辑。

我想从其他类访问 var1。

c#

2
推荐指数
1
解决办法
206
查看次数