c# - Github api 使用 octokit.net 获取按标签过滤的问题

标签 c# asp.net-mvc github-api octokit.net

目前,我对 GitHub API 的调用返回了我的存储库的所有问题。

var repoIssueRequest = new RepositoryIssueRequest
{
    State = itemState,// Is ItemState.Open or ItemState.Closed
    Labels = new[] { label1, label2}// Trying to specify the labels I want to filter by, but there is no set, so this won't work
};

var gitRepoIssues = (_gitHubclient.Issue.GetForRepository(string owner, string repo name, repoIssueRequest)).Result.ToList();

我不仅要指定是打开问题还是关闭问题,还要通过标签来指定。规范 (View Here)将标签指定为参数之一,但在 octokit.net 中我无法指定标签列表,因为它只有 getter 访问器。

RepositoryIssueRequest工具 IssueRequest , 和 IssueRequest包含 public Collection<string> Labels { get; } .

目前,我在获取所有问题后按标签进行过滤,但如果要返回几百个问题然后过滤这个问题集合,则必须返回大量数据。如何指定标签,以便减少返回问题集合所需的时间?

最佳答案

我在 Octokit.net 存储库上打开了一个问题,并得到了我的问题的答案。

var repoIssueRequest = new RepositoryIssueRequest
{
    State = itemState,// Is ItemState.Open or ItemState.Closed
    //Labels = new[] { label1, label2}// Don't specify label names here
};

repoIssueRequest.Labels.Add("Label1");// Repeat for label 2 and so on or use .AddRange()

var gitRepoIssues = (_gitHubclient.Issue.GetForRepository(string owner, string repo name, repoIssueRequest)).Result.ToList();

感谢 shiftkey 对我的问题的快速响应

关于c# - Github api 使用 octokit.net 获取按标签过滤的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29141747/

相关文章:

c# - 真正基本的 C# 数组/循环混淆

github - 使用 sourcegraph 在 github 存储库中搜索带有特殊字符的术语?

git - 如何在不克隆 GITHUB 的情况下查找 Git 存储库的修订 ID

javascript - 在 MVC 4 中一起使用模型和 javascript 中的值

Github 权限

c# - Xaml 不是破坏了我的封装吗?

c# - 为什么会出现此 System.NullReferenceException?

c# - 当我调用 Scan() 方法时 ZXing.Net.Mobile 条码扫描器错误

c# - Entity Framework 错误。底层提供程序打开失败无法附加文件

c# - 将选定值的集合从 Select2-Multi DropDownList 传递到 Controller