How can I retrieve a list of workitems from TFS in C#?

一个人想着一个人 提交于 2019-12-03 01:02:40
Oleg Mikhaylov

You need to use WIQL queries to get actual work items you are interested in, e.g. to get all work items for a particular project:

using Microsoft.TeamFoundation.WorkItemTracking.Client;

Query query = new Query(
     workItemStore, 
     "select * from issue where System.TeamProject = @project",
     new Dictionary<string, string>() { { "project", project.Name } }
);

var workItemCollection = query.RunQuery();
foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem in workItemCollection) 
{
   /*Get work item properties you are interested in*/
   foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.Field field in workItem.Fields)
   {
      /*Get field value*/
      info += String.Format("Field name: {0} Value: {1}\n", field.Name, field.Value);
   }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!