-1

Is it possible to get list of query names that is present in the particular iteration path in TFS SDK ?

I am able to get all the query names of a project using the following code

foreach (StoredQuery qi in detailsOfTheSelectedProject.StoredQueries)
        {
            cmbQueries.Items.Add(qi.Name);
        }

But, that I don't need, instead I need to get the query names for the particular iteration path.

I also referred this question in Stack Overflow, but not found any answer.

Community
  • 1
  • 1
user3747256
  • 113
  • 1
  • 1
  • 13

1 Answers1

1

The easiest way will be to check the contents of the QueryText property of the StoredQuery object, e.g.

string iterationPath;
foreach (StoredQuery qi in detailsOfTheSelectedProject.StoredQueries)
{
    if(qi.QueryText.Contains(iterationPath)) cmbQueries.Items.Add(qi.Name);
}
Oleg Mikhaylov
  • 1,124
  • 7
  • 10
  • Consider a Query `All Items` which has `Team Project = @Project` and `Work Item Type = [Any]`. In this query also, The Iteration Path that I had selected is present. So, `QueryText` does not contain the `iteration path` text here. How to handle this type of cases. Thanks. – user3747256 Jun 02 '15 at 05:27
  • Can you clarify what do you mean by saying 'the Iteration Path is present'? Do you mean that this query (All Items) returns work items in the iteration path you have selected? – Oleg Mikhaylov Jun 02 '15 at 18:17
  • yes, exactly you are correct. I meant to this query (All Items) returns work items in the iteration path that has been selected. Thanks. – user3747256 Jun 04 '15 at 10:21
  • Then the only way I can think of to do it is to run each query and loop through the results checking if work item iteration path is the one you are interested in. It can be pretty slow. – Oleg Mikhaylov Jun 05 '15 at 02:04