我在TFS 2013中创建了一个查询,如下所示:
当我在TFS中运行此查询时,结果包含符合源条件的所有工作项,无论它们是否具有链接。
以上查询生成以下WIQL(如果我保存为文件):
SELECT [System.Id], [System.Links.LinkType], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags]
FROM WorkItemLinks
WHERE ([Source].[System.TeamProject] = @project)
And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Reverse')
ORDER BY [System.Id] mode(MayContain)
但是,当我运行以下powershell时,生成的sourceIds只包含具有父链接的工作项:
$CollectionUrl = "myCollectionUrl"
$ProjectName = "myProjectName"
'Microsoft.TeamFoundation.Client', 'Microsoft.TeamFoundation.Common', 'Microsoft.TeamFoundation.WorkItemTracking.Client' |
ForEach-Object {
Add-Type -AssemblyName "$_, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
}
[Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)
[Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore]$wis = `
New-Object -TypeName Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore `
-ArgumentList ($tfs, [Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStoreFlags]::BypassRules)
[string] $WIQL = "SELECT [System.Id], [System.Links.LinkType], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags]
FROM WorkItemLinks
WHERE ([Source].[System.TeamProject] = '$projectName')
And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Reverse')
ORDER BY [System.Id] mode(MayContain)"
$query = New-Object "Microsoft.TeamFoundation.WorkItemTracking.Client.Query" -ArgumentList $wis, $WIQL
$workItemLinkInfo = $query.RunLinkQuery()
$workItemLinkInfo | out-gridview
为什么WIQL在通过API时的行为与通过UI执行时的行为不同?或者有人可以看到我哪里出错了?