WIQL Query to get all Child and sub-Child work items in C#

26 March 2022 | Viewed 4594 times

WIQL stands for Work Item Query Language, and it is used to query work items from Azure DevOps. Using this query we can query Work Item Details or Related Work Items. The WIQL syntax is used to execute the Query By Wiql REST API.

Here is the example to query the list of all child work items and sub-child work items for a give Parent work item Id.

<b>WorkItemLinks</b> links table will have the work items and its related work items.
To get child of child work items we have to use ?"mode (Recursive, ReturnMatchingChildren)".

C# Code
from WorkItemLinks
where ( [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward')
and (Target.[System.Id] = 1234)
order by [System.Id]
mode (Recursive, ReturnMatchingChildren)