IGraphServiceUsersCollectionRequest (GraphServiceClient) 的部门非空过滤器

发布于 2025-01-16 09:16:24 字数 332 浏览 0 评论 0原文

如何为部门属性创建非空过滤器以通过GraphServiceClient获取用户?

department ne null

并且

NOT(department eq null)

不起作用

我当前的代码:

var request = _graphClient.Users.Request()
    .Filter($"department ne null");
        
var usersPage = await request.GetAsync();

How to create not null filter for department property to get users by GraphServiceClient?

department ne null

and

NOT(department eq null)

don't work

My current code:

var request = _graphClient.Users.Request()
    .Filter(
quot;department ne null");
        
var usersPage = await request.GetAsync();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风向决定发型 2025-01-23 09:16:24

department 过滤需要添加标头 ConsistencyLevel:eventual,并且 $count 参数必须设置为 true

根据文档 department 仅在 $select 上返回。这意味着,如果您需要知道 department 的值,则必须添加 Select 方法并指定要返回的所有属性,包括 department

var queryOptions = new List<QueryOption>()
{
    new HeaderOption("ConsistencyLevel", "eventual");
    new QueryOption("$count", "true")
};

var request = await _graphClient.Users
    .Request( queryOptions )
    .Select("id,displayName,department") // and other properties
    .Filter("department ne null"); // .Filter("NOT(department eq null)") should also work

var usersPage = await request.GetAsync();

资源:

高级查询

用户属性

Filtering by department requires adding header ConsistencyLevel:eventual and $count parameter must be set to true.

According to the documentation department is returned only on $select. It means that if you need to know the value of department you have to add Select method and specify all properties to be returned including department.

var queryOptions = new List<QueryOption>()
{
    new HeaderOption("ConsistencyLevel", "eventual");
    new QueryOption("$count", "true")
};

var request = await _graphClient.Users
    .Request( queryOptions )
    .Select("id,displayName,department") // and other properties
    .Filter("department ne null"); // .Filter("NOT(department eq null)") should also work

var usersPage = await request.GetAsync();

Resources:

Advanced queries

User properties

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文