I have the following tfs wiql query that returns me an item and all linked items (child, related, etc.):
var query = string.Format("SELECT * FROM WorkItemLinks WHERE " +
"Source.[System.Id] IN ({0}) " +
"AND (Target.[System.State] <> 'Deleted'" +
"AND (Target.[System.WorkItemType] = 'eScrum Sprint Task' OR Target.[System.WorkItemType] = 'Bug') " +
"AND Target.[System.Title] not contains 'css') mode(MayContain)", storiesRange);
How to restrict this query so that it returns linked items only of child type?
If you have no idea how to write some WIQL for your customized work item query.
You could first use visualization window to create your work item query in web portal UI.
Such as below:
Then save the query and open the query in visual studio. Or you could use some 3-party extension such as this one-- Wiql Editor
It will directly transfer the work item query to WIQL language. For example the WIQL of above query should be:
So according to above info to restrict this query so that it returns linked items only of child type, you should add this restriction:
[System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'