3

I have a working utility that queries the TFS workitem store via the TFS API. I can retrieve various pieces of data in this way including listing the Stored query names. However, I can't find the location of Custom Queries. Can anybody point me in the right direction?

Thanks

Kevin Roche
  • 367
  • 1
  • 11

2 Answers2

5

You mentioned you can't find custom query, in which folder? Team Query or My Query, anyway if you mean my Query, you will need to write code like the following:

var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFS2011:8080/TFS/DefaultCollection"));
        var workItemStore = tfs.GetService<WorkItemStore>();
        var queryHirerarchy = workItemStore.Projects[5].QueryHierarchy;
        foreach (QueryFolder query in queryHirerarchy)
            {
            Console.WriteLine(query.Name);
            } 

But remember My team Queries will be per login credential enter image description here

Thanks

M.Radwan

Mohamed.Radwan -MVP
  • 2,724
  • 2
  • 16
  • 24
  • Excellent thanks, that's almost exactly what I needed. With just the addition of a loop over the QueryDefinitions within the QueryFolder I can pull out the information I'm after: – Kevin Roche Aug 18 '11 at 09:15
0

I think the info you 're after resides in the TFS-DB named after your Team Project Collection (Tfs_YourCollectionName), under table dbo.QueryItems
I wouldn't know of an API method to obtain the info contained in the columns, directly selecting with SQL on the table should work anyhow (given that you have access).

pantelif
  • 8,524
  • 2
  • 33
  • 48
  • Thanks. My original aim was to jump into the database tables and pull the data that I need directly from them, however, "corporate policy" prevents me getting the necessary access to the database tables. – Kevin Roche Aug 18 '11 at 08:33
  • yeah, I think @M.Radwan 's approach is much safer if it gets you what you need. – pantelif Aug 18 '11 at 09:30