TFS API: Iv. Work Item Queries

Source: Internet
Author: User

TFS API: Iv. Work Item Queries

This section describes how to query a work item to set user statistics.

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

Select [title]

From WorkItems

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

Order BY [title]

We learn through several steps,

First, the basic query

Remove the project name under the Team collection URI and, if the team collection is empty, take the project under the default collection

Uri Tfsuri = new Uri ("Http://10.0.9.142:8080/tfs/web");//This will calueng the team to assemble the project

Tfsteamprojectcollection Server = new Tfsteamprojectcollection (Tfsuri);

WorkItemStore workstore = server. Getservice<workitemstore> ();

Basic Query

Workitemcollection queryresults = Workstore. Query (@ "SELECT [title] FROM WorkItems Where [work item Type] = ' Bug '");

foreach (WorkItem item in QueryResults)

{

Console.WriteLine ("Work Item Name:" + item.) Title);

}

Second, multi-conditional query and sorting

Workitemcollection itemcollection = Workstore. Query (@ "SELECT [title] FROM WorkItems

Here [Work item type]= ' Bug ' and [Assigned to] in (' xxxxxx ') and [severity level]= ' 3-medium ' ORDER by [title] ");

foreach (WorkItem item in ItemCollection)

{

Console.WriteLine ("Work Item Name:" + item.) Title);

}

Iii. Number of query results

String queryString = @ "SELECT [title] FROM WorkItems WHERE [work item type]= ' Bug ' and [Assigned to] in (' V-yangrui Wind ')";

Query query = new query (Workstore, queryString);

int numworkitems = query. Runcountquery ();

Console.WriteLine ("Number of work Items" + numworkitems);

Iv. Conditions for Query statements

Work items in VS, select the column option, where you can edit the display of the work item, and the column is the condition. Because I personally tested a lot of the conditions that need to be used for screening are related to this, but because of the reasons for the data, many conditions have no way to test, personal guess, when editing query statements, the condition as long as the column name.

Five, the query results show

TFS API: Iv. Work Item Queries

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.