按公司名称过滤的 MS 图形不起作用



有两个类似的片段:

IGraphServiceUsersCollectionPage users = await graphServiceClient.Users
.Request()
.Select("id")
.Filter("department eq 'Department'")
.GetAsync();

IGraphServiceUsersCollectionPage users = await graphServiceClient.Users
.Request()
.Select("id")
.Filter("companyName eq 'CompanyName'")
.GetAsync();

第一个片段工作正常;第二个片段根本不起作用

我已经成功通过HTTP GET直接请求

https://graph.microsoft.com/beta/users?ConsistencyLevel=eventual&$count=true&$filter=companyName eq 'Company'

所以现在我有一个问题:我如何在c#中使用MSGraph API ?

要在查询中添加$count=true,您应该使用QueryOption

var options = new List<QueryOption>();
options.Add(new QueryOption("$count", "true"));
IGraphServiceUsersCollectionPage users = await graphServiceClient.Users
.Request(options)
.Select("id")
.Filter("companyName eq 'CompanyName'")
.GetAsync();

Azure AD目录对象的高级查询功能

查询参数自定义查询