I need to get the queries in TFS 2012 in the "My Queries" folder. I found this article. But following that gives all the queries.
I want to get queries from the "My Queries" folder. This is what i have tried so far:
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;
}
When i add queryFolder
to watch it gives following output:
How an I access the result and get those values?
I solved this problem following way:
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With