TFS API - 如何获取特定团队项目工作项目(S) [英] TFS API - How to fetch work item(s) from specific Team Project

查看:1142
本文介绍了TFS API - 如何获取特定团队项目工作项目(S)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图查询其总共包含194团队项目的主要 TfsTeamProjectCollection 一个团队项目。我知道如何从 WorkItemStore 获得工作项按标识。关键是,通过这样做,在集合中的项目的所有的API的搜索和查询需要大约一分钟。这是太慢,必须有直接从一个团队项目查询工作项目的方式吗?这里是我的代码:

I am trying to query a single team project in the main TfsTeamProjectCollection which contains 194 Team Projects in total. I know exactly how to get a WorkItem by Id from a WorkItemStore. The thing is, that by doing this, the API searches in ALL of the projects in the collection and the query takes about a minute. This is way too slow, there must be a way to query work items directly from a single team project ? Here is the code I have:

    private Uri collectionUri;
    private TfsTeamProjectCollection projectCollection;
    private WorkItemStore workItemStore;

    public Project GetTeamProject()
    {
        projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(collectionUri);

        workItemStore = projectCollection.GetService<WorkItemStore>();
        Project teamProject = workItemStore.Projects[TFS_PROJECT_KEY];
        return teamProject;
    }

现在,我有团队项目我感兴趣的,我怎么能通过ID或者只是获得这个项目的所有工作项目的工作项查询?

Now that I have the Team Project I'm interested in, how can I query for work items by ID or just get all work items in this project ?

推荐答案

这可能是最有效的的use查询找到工作项目你有兴趣,你可以添加一个如果项目='@project'到查询到的范围限制在这一点的项目。首先调用BeginQuery然后EndQuery你会得到一个工作项目集合只是你正在寻找的项目。

It's probably most efficient to use a query to find the workitems you're interested in. You can add a Where project = '@Project' to the query to limit the scope to just that project. By first calling BeginQuery and then EndQuery you'll get a workitem collection for just the items you were looking for.

要获得所需的WQL查询的最简单的方法是创建在团队资源管理器的查询,那么文件 - >使用另存为(在编辑模式下),将其保存到文件。打开该文件在记事本中复制查询离开那里。

The easiest way to get the required wql query is to create a query in Team Explorer, then use file->save as (in edit mode) to save it to file. Open that file in Notepad to copy the query out of there.

另外,您可以使用的 WorkItemStore.Query方法是直接来实现同样的事情。

Alternatively you can use the WorkItemStore.Query method directly to achieve the same thing.

这篇关于TFS API - 如何获取特定团队项目工作项目(S)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆