Tuesday, April 13, 2010

TFS 2010 Work Item Link Queries

To extend our ALM offering, we are building some custom tools that interact with TFS 2010 work item tracking via the client object model

I noticed one very strange thing while implementing some query features. When querying for links, we specify "FROM WorkItemLinks" in the WIQL and then use Query.RunLinkQuery() to get the results. The results consist of an array of WorkItemLinkInfo objects. These contain only the link type, and the source and target work item IDs. So specifying anything other than "SELECT [System.Id], [System.Links.LinkType]" has no effect.

But if we look at the built-in link based queries in VS2010 and examined their WIQL, there are always tons of fields in the SELECT clause even though they specify "WorkItemLinks" in their FROM clause. If I run one of those queries from the client object model those fields aren’t returned.

I’m  speculating that Team Explorer  does some of kind of parsing that converts the WorkItemLinks query to a combination of WorkItems and WorkItemLink queries.

Anyone who knows if I’m correct?

2 comments:

Dan Ledrick said...

Bart,
You must be correct. I found your post as I've been stumbling around the internet trying to find out how to run a fairly simple Parent/Child (ie, link) query in managed code vs. running in Excel or TFS client.

The only way I have it work now is to run the WorkItemLink query to get the array, and then loop the array. The performance is horrid, and there is clearly a better way to do it since Excel, TFS Web Application and TFS itself has not problem! If you have discovered anything, please let me know!

Anonymous said...

Has anyone discovered an efficient coded solution to be able to return the WorkItem info of the items returned from the WorkItemLinks table?