6

我需要在“我的查询”文件夹中获取 TFS 2012 中的查询。我找到了这篇文章。但是接下来会给出所有的查询。

文件夹层次结构

我想从“我的查询”文件夹中获取查询。这是我到目前为止所尝试的:

string selectedProject = this.listProjects.SelectedItem.ToString();
TfsTeamProjectCollection teamProjectCollection = TFSDetail.GetTeamProjectDetails(UrlPath);
if (teamProjectCollection != null)
{
     Project detailsOfTheSelectedProject = null;
     WorkItemStore workItemStore = 
           (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));

     string folder = "My Queries";
     var project = workItemStore.Projects[selectedProject];
     QueryHierarchy queryHierarchy = project.QueryHierarchy;
     var queryFolder = queryHierarchy as QueryFolder;
     QueryItem queryItem = queryFolder[folder];
     queryFolder = queryItem as QueryFolder;               
}

当我添加queryFolder观看时,它会给出以下输出:

观察窗口

我如何访问结果并获得这些值?

4

1 回答 1

7

我通过以下方式解决了这个问题:

var project = workItemStore.Projects[selectedProject];
QueryHierarchy queryHierarchy = project.QueryHierarchy;
var queryFolder = queryHierarchy as QueryFolder;
QueryItem queryItem = queryFolder[folder];
queryFolder = queryItem as QueryFolder;
foreach (var item in queryFolder)
{
     listQueries.Items.Add(item.Name);
}
于 2013-07-24T06:28:13.007 回答