IGraphServiceUsersCollectionRequest (GraphServiceClient) 的部门不是空过滤器
Department not null filter for IGraphServiceUsersCollectionRequest (GraphServiceClient)
如何为部门 属性 创建非空过滤器以通过 GraphServiceClient 获取用户?
department ne null
和
NOT(department eq null)
不工作
我当前的代码:
var request = _graphClient.Users.Request()
.Filter($"department ne null");
var usersPage = await request.GetAsync();
按 department
过滤需要添加 header ConsistencyLevel:eventual
并且 $count
参数必须设置为 true
.
根据 documentation 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();
资源:
如何为部门 属性 创建非空过滤器以通过 GraphServiceClient 获取用户?
department ne null
和
NOT(department eq null)
不工作
我当前的代码:
var request = _graphClient.Users.Request()
.Filter($"department ne null");
var usersPage = await request.GetAsync();
按 department
过滤需要添加 header ConsistencyLevel:eventual
并且 $count
参数必须设置为 true
.
根据 documentation 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();
资源: