Search code examples
tfstfs-sdk

Custom TFS queries via the API


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


Solution

  • 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