TFS 2010 work item - Work item links

旧巷老猫 提交于 2019-12-11 01:59:18

问题


When a user opens a bug from a test case, I need to check if the test case is linked to a requirement item and if so I need to link the bug to the requirement item.

How can I know this information?

I use following piece of code:

WorkItemLinkCollection links = _workItem.WorkItemLinks;
foreach (WorkItemLink link in links)
{

}

but I don't know how to get the link type and link id.


回答1:


WorkItemLink is an abstract base class. ExternalLink, HyperLink, and RelatedLink inherit from it so the link instance will be one of those types. So, check the type of your instance or test it with 'is'. You can also get the RegisteredLink property which gets the friendly name of the link type.

For more info see http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.link(v=vs.80).aspx

Concerning the id that it's related to, each type is related to something different. For example, the RelatedLink type has a RelatedWorkItemId property which returns the id of the workitem that this workitem is related to. The source id is the id of the workitem that the link collection is on.

http://msdn.microsoft.com/en-US/library/microsoft.teamfoundation.workitemtracking.client.relatedlink_members(v=VS.80).aspx

But, a hyperlink link isn't related to another workitem - it has a location property to get the hyperlink location as a string.

http://msdn.microsoft.com/en-US/library/microsoft.teamfoundation.workitemtracking.client.hyperlink_members(v=VS.80).aspx



来源:https://stackoverflow.com/questions/8668053/tfs-2010-work-item-work-item-links

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!