Does anyone has any idea h开发者_高级运维ow we can retrieve all linked work item in TFS from a given work item. Code snippet will be of great help
Do you mean a work item linked to a specific project in TFS? If so, use TFS queries like so:
string project = "Project1";
string type = "Bug";
string me = SystemInformation.UserName.Replace(".", " ");
string query = string.Format("SELECT [System.Id], [System.WorkItemType], [System.State], [System.AssignedTo], [System.Title] FROM WorkItems WHERE [System.AssignedTo] = {0} AND [System.TeamProject] = {1} AND [System.WorkItemType] = {2} AND [System.State] <> '" + "Closed" + "' AND [System.State] <> '" + "Resolved" + "' ORDER BY [System.Title] ASC", me, project, type);
TeamFoundationServer tfs;
WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
WorkItemCollection wic = wis.Query(query);
And then you should be able to foreach around the work items which gives you details of the particular one, obviously to change the project or type of item, change it in the query. To work with TFS you will need to have referenced most of the namespaces in Microsoft.TeamFoundation.
精彩评论