AngryHacker
AngryHacker

Reputation: 61596

How to get all work items in an iteration?

I am using TFS client side libraries, e.g Microsoft.TeamFoundation.* assemblies... Given that I have an Iteration name, how do I retrieve all the work items that belong to it?

I've tried the following using the Query object:

var uri = new Uri(ConfigurationManager.AppSettings["TfsUri"]);
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);
var wiStore = tfs.GetService<WorkItemStore>();

var queryText = "select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] from WorkItems where [System.TeamProject] = 'VieroSAT'  and [System.State] = 'Dev'  order by [System.Id]";
var query = new Query(wiStore, queryText);

but I can't figure out how to limit results by Iteration Name. And I'd much rather return these values using the TFS assemblies, but I can't find the appropriate method.

So my questions...

  1. How to return a list of all work items in an iteration, using the TFS Assemblies only (e.g. no queries).
  2. If #1 is not possible, how do I do the above but using a Query object.

Upvotes: 6

Views: 4594

Answers (1)

vlad
vlad

Reputation: 4778

I don't have a quick way of testing this, but according to msdn, you can use the Under comparison operator in your query. However, I'm not sure what field you would use in that where clause to compare against the iteration name. Perhaps something like this:

select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State]
from WorkItems
where
  [System.TeamProject] = 'VieroSAT'
  and [System.State] = 'Dev'
  and [System.IterationPath] Under 'Iteration1'
order by [System.Id]

Upvotes: 7

Related Questions