WIQL树查询从单个子Id获取所有父工作项?

时间:2017-01-25 00:48:44

标签: c# asp.net-mvc tfs wiql azure-devops-rest-api

我有这个WIQL ......

Wiql wiql = new Wiql()
  {
    Query = string.Format("SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State]" +
                          " FROM WorkItemLinks" +
                          " WHERE Target.[System.TeamProject] = '{0}'" +
                          " AND Source.[System.Id] = {1}" +
                          " AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'" +
                          " mode(Recursive)", project, startingChildId)
  };

我想让它匹配这个TFS查询,其中特定工作项的所有父项都放入树中,如下所示。

enter image description here

我的问题是我只从我想要父工作项的案例中获取子工作项。我怎样才能遍历树而不是树?我已经尝试将System.Links.LinkType切换到等效的父关系,但这样做会引发不支持的错误。

1 个答案:

答案 0 :(得分:5)

检查下面的WIQL:

select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] from WorkItemLinks where ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') and (Target.[System.Id] = 4839) order by [System.Id] mode (Recursive, ReturnMatchingChildren)