How To: Create and Use Team Foundation Server 2010 Queries

This is Syed Aslam Basha here from Information security and risk management team.

Lets explore the basics of creating and using queries in Team foundation server (TFS).

First and foremost you should connect to the project for which you want to create queries as;

  • Launch the visual studio
  • Click on View – > Team explorer
  • Click on the connect to team project in the team explorer 
    1
  • Click on servers button
  • Click on add button
  • Enter the name of the TFS
  • Click on ok
  • Click on close
  • Select the required project from team project collections
  • Select the required projects and click on connect
  • The team explorer should show 
    2
  • Expand the project and work Items 
    3
  • You should see two group of queries; my queries and team queries
  • My queries: User can create/modify/delete the queries here, which  are personal queries available to user only
  • Team queries: You need to have project administrator permissions to create/modify/delete queries here, these are available to entire team
  • The process of creating/modify/delete remains same in either of the groups
  • Right click on the my queries and select new query 
    4
  • There are three types of queries
      5
    • Flat list (Default) – The query result set of this type will be depend on only work items only; it will return only list of items without any filter; similar to that of TFS 2008 feature; Example for bugs work item type, the query result is ( click on run to see the query result)
      6
    • Work Items and Direct Links – The query result set of this type will depend on
      • Flat list
      • Linked work items query and
      • linking filters 
        7
      • Useful for work item types like tasks which will have sub tasks and want to list all Task items along with sub task items based on linking filters
      • In the above example, first section will give result set of all Task items, second section will give all linked task items for each task and filters based on return all top level work items and return links of any type and the result is; ( Click on run button to see the query result)
        8
      • Click on the fly out in title to see the sub tasks
      • Linking filters: We have two groups of linking filters
        • Top level work items: This has three types
          • Return all top level work items – Returns all top level work items
          • Only return items that have the specified links – Returns items based on the type of links specified (see next section)
          • Only return items that do not have the specified links – Reverse of the second type
        • Types of links: There are two types of links
          • Return links of any type – returns links irrespective of the link type ( Creating links and its usage would be covered in the next blog post)
          • Return selected link types – Returns only selected link types. Example say set child type of link and top level work items as only return items that have specified links will give query result having work items with sub work items; ( Click on run button to see the query result)
            9  
          • Similarly you can try other combinations
    • Tree of work items – The query result of this type depends on flat list and linked work items. Example the query result set shows all task items in tree mode ( Click on run button to see the query result)
      10
  • Make the required selections and click on save query
  • Click on Run to see the query result

- Syed Aslam Basha ( syedab@microsoft.com )

Microsoft Information Security Tools (IST) Team

Test Lead

---------------------------------------------------------

Please leave a comment if the blog post has helped you.