I'd like to query for all WorkItems which:
This is what I've tried:
string itemsMarkedDuplicateParentFixed = "Select [Target].[ID] From WorkItemLinks Where " +
"[Source].[System.WorkItemType] = 'Bug' And " +
"[Target].[System.WorkItemType] = 'Bug' And " +
"[Source].[System.State]='Resolved' And " +
"[Source].[Microsoft.VSTS.Common.ResolvedReason]='Duplicate' And " +
"[Target].[System.State]='Resolved' And " +
"[Target].[Microsoft.VSTS.Common.ResolvedReason]='Fixed' And " +
"[Source].[System.CreatedBy] = 'TomSelleck' And " +
$"[Target].[Microsoft.VSTS.Common.ResolvedDate]>='{resolvedDateFrom}' And" +
$"[Target].[Microsoft.VSTS.Common.ResolvedDate]<='{resolvedDateTo}'";
IEnumerable <WorkItem> appCompatBugsMarkedFixed = await vsoService.GetWorkItems(new Wiql() {
Query = appCompatBugsMarkedDuplicateParentFixed
});
...
public async Task<IEnumerable<WorkItem>> GetWorkItems(Wiql wiqlQuery)
{
using (var workClient = await GetClient())
{
var queryResults = await workClient.QueryByWiqlAsync(wiqlQuery);
return await workClient.GetWorkItemsAsync(queryResults.WorkItemRelations.Select(x => x.Target.Id), expand: WorkItemExpand.All);
}
}
I'm hitting this error:
Microsoft.VisualStudio.Services.WebApi.VssServiceResponseException: 'Not Found'
I'm struggling to find any C# examples which achieve what I want.
Did you try your query through Web or Visual Studio designer? You can create a query, test it and then export it on VS (Retrieve the WIQL of a saved query created in TFS) or Wiql Editor. The example similar to your query:
Query in the designer:
Query wiql: