Premier Field Engineer, Microsoft Services Customer Service and Support
Yesterday I got another question on one of our internal mailing list and I remembered it as one that I’ve answered before on OzTFS.com. The answer comes from this MSDN forum post.
By default, the TFS Work Item Query engine operates in “date precision” mode. This means that you can only run queries like:
If you want to query on work items changed within a narrower timeframe, you’ll need to call the object model directly and turn off “date precision” mode. For example:
using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.WorkItemTracking.Client; namespace WorkItemQueryByHour { class Program { static void Main(string[] args) { TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://your-tfsserver:8080", new UICredentialsProvider()); WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); Query query = new Query(wis, "SELECT [System.Id], [System.Title], [System.ChangedDate] FROM WorkItems WHERE [System.ChangedDate] > '2008-10-01 05:00:00'", null, false); ICancelableAsyncResult car = query.BeginQuery(); WorkItemCollection items = query.EndQuery(car); } } }
using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace WorkItemQueryByHour { class Program { static void Main(string[] args) { TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://your-tfsserver:8080", new UICredentialsProvider()); WorkItemStore wis = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
Query query = new Query(wis, "SELECT [System.Id], [System.Title], [System.ChangedDate] FROM WorkItems WHERE [System.ChangedDate] > '2008-10-01 05:00:00'", null, false);
ICancelableAsyncResult car = query.BeginQuery(); WorkItemCollection items = query.EndQuery(car);
} } }
Shai Raiten on Power Tools 2008 - TFSUsers/TFSManager and How To: Add Custom Build Steps to TeamBuild...