As mentioned earlier, work items have their own query language, called the Work Item Query Language (WIQL). This language is a SQL-like construct that, when used in conjunction with the work item tracking object model, can be used to build powerful queries that retrieve detailed information from the work item tracking system.
This section will give you a brief primer on the Work Item Query Language. For all the details, you should check out the documentation provided in the Visual Studio SDK. For this brief primer, you will learn about the different aspects of a WIQL query, and then see a short application that uses a WIQL query.
Every WIQL query consists of a SELECT statement, containing the fields to retrieve, and a WHERE statement to help determine what information to retrieve. So a sample query to retrieve all the work item ids assigned to Developer1 might look like this:
System.ID from workitems where System.AssignedTo = 'Developer1'
You always must specify the fields you are interested in. When specifying fields, you can use either the friendly name or the reference name. In the above example, we have used the reference name. Best practices dictate that you use reference names at all times, as these will never change, while friendly names may change at some point in the future. You can select any field type in a query, except for plain text fields. And all your standard operators, such as =, >, and <, work in the WHERE clause section. ...