Microsoft.graph SDK搜索成员组的组[X&quot] startwith; a; a;

发布于 2025-01-19 14:24:37 字数 1137 浏览 0 评论 0原文

我想将此 OData 转换复制到我的 DOTNET 核心项目中:

我正在使用 Microsoft.Graph (4.2.0) nuget 包

这是我的 OData 转换,可以在 Graph Explorer 中正常工作。 (https://developer.microsoft.com/en-us/graph/graph -资源管理器)

https://graph.microsoft.com/v1.0/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/members?$count=true&$filter=startswith(displayName, 'A')

这是我的代码:

var queryOptions = new List<QueryOption>();
queryOptions.Add(new QueryOption("$count", "true"));

var groupMembers = await graphClient.Groups[$"{groupId}"].Members
                .Request(queryOptions)
                .Header("ConsistencyLevel", "eventual")
                //.Filter("startswith(displayName, 'E')")
                //.Search("displayName:Eric")
                .GetAsync();

当我尝试运行:

.Filter("startswith(displayName, 'E')")

我收到错误:

代码:Request_UnsupportedQuery 消息:当前不支持引用属性查询的指定过滤器

我无法使用 .Search,因为 “IGroupMembersCollectionWithReferencesRequest”不包含搜索定义

I would like to replicate this OData cast into my DOTNET core project:

I am using Microsoft.Graph (4.2.0) nuget package

This is my OData cast that works fine in Graph Explorer. (https://developer.microsoft.com/en-us/graph/graph-explorer)

https://graph.microsoft.com/v1.0/groups/02bd9fd6-8f93-4758-87c3-1fb73740a315/members?$count=true&$filter=startswith(displayName, 'A')

This is my code:

var queryOptions = new List<QueryOption>();
queryOptions.Add(new QueryOption("$count", "true"));

var groupMembers = await graphClient.Groups[
quot;{groupId}"].Members
                .Request(queryOptions)
                .Header("ConsistencyLevel", "eventual")
                //.Filter("startswith(displayName, 'E')")
                //.Search("displayName:Eric")
                .GetAsync();

When I try to run with:

.Filter("startswith(displayName, 'E')")

I receive the error:

Code: Request_UnsupportedQuery Message: The specified filter to the reference property query is currently not supported

I cannot use .Search because
'IGroupMembersCollectionWithReferencesRequest' does not contain a definiton for Search

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

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

发布评论

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

评论(1

凉宸 2025-01-26 14:24:37

以下代码对我有用:

string userGroupNameFilter = $"startswith(displayName,'CT-')";
List<Option> graphRequestOptions = new List<Option>() {
                                                        new QueryOption("$count", "true")
                                                      //,new QueryOption("$filter", userGroupNameFilter)
                                                      //,new HeaderOption("ConsistencyLevel", "eventual")
                                                       };
var userGroups = await graphClient.Users[$"{user.Id}"].TransitiveMemberOf
                                  .Request(graphRequestOptions)
                                  // .Header("Prefer", "odata.maxpagesize=100")
                                  .Header("ConsistencyLevel", "eventual")
                                  //.Header("Count", "true")
                                  .Filter(userGroupNameFilter)
                                  .GetAsync();

The following code worked for me:

string userGroupNameFilter = 
quot;startswith(displayName,'CT-')";
List<Option> graphRequestOptions = new List<Option>() {
                                                        new QueryOption("$count", "true")
                                                      //,new QueryOption("$filter", userGroupNameFilter)
                                                      //,new HeaderOption("ConsistencyLevel", "eventual")
                                                       };
var userGroups = await graphClient.Users[
quot;{user.Id}"].TransitiveMemberOf
                                  .Request(graphRequestOptions)
                                  // .Header("Prefer", "odata.maxpagesize=100")
                                  .Header("ConsistencyLevel", "eventual")
                                  //.Header("Count", "true")
                                  .Filter(userGroupNameFilter)
                                  .GetAsync();

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