TFS Work Item Query

Source: Internet
Author: User
Tags foreach

This section describes how to query work items for use in two development definitions to obtain a work item list.

Query work items by using the Workitemstore.query method, which uses the same syntax as the SQL syntax:

Select [title]

From WorkItems

Where [Work Item Type]= ' Task ' and [assigned to] = ' Administrator '

Order BY [title]

We learn through several steps, first, we connect TFS services:

Tfsuri
uri Tfsuri = new Uri ("Http://pc-20130113jkun:8080/tfs");
Tfsteamprojectcollection projectcollection = new Tfsteamprojectcollection (Tfsuri);
WorkItemStore WorkItemStore = (workitemstore) projectcollection.getservice (typeof

(WorkItemStore));

Second, basic inquiries

Basic Query
            workitemcollection queryresults = workitemstore.query (@)
                select  [title] from 
                WorkItems
                Where [Work Item Type] = ' Bug ' ");
            foreach (WorkItem item in QueryResults)
            {
                Console.WriteLine ("Work Item Name:" +item. Title+ "Work Item Description:" +item. Description);
            }

Three, multiple conditions query and sorting

Console.WriteLine ("--------------------------

multiple criteria query and Sorting-------------------------");
            Multi-condition query and sort
            workitemcollection itemcollection = workitemstore.query (@ Select [title] FROM WorkItems 
                where [work item type] = ' Task ' and [assigned to] = ' Administrator ' order by [title] ';
            foreach (WorkItem item in itemcollection)
            {
                Console.WriteLine ("Work Item Name:" + item.) Title + "Work Item Description:" + Item. Description);
            }

Iv. Number of query results

Console.WriteLine ("--------------------------Number of query

results-------------------------");
            Query result quantity
            string querystring = @ "SELECT  [title] FROM WorkItems Where [work item Type] = ' Bug '";
            Query query = new query (workitemstore,querystring); 
            int numworkitems = query. Runcountquery ();
            Console.WriteLine ("Number of work Items" + Numworkitems + "user Stories.");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.