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