using Microsoft.TeamFoundation.Client; var tfsUri = new Uri("http://mytfsserver:8080/tfs/MyCollection"); var projectCollection = new TfsTeamProjectCollection(tfsUri); projectCollection.EnsureAuthenticated();
using Microsoft.TeamFoundation.WorkItemTracking.Client; var project = projectCollection.GetServiceThis code queries work items assigned to the current user in a TFS project named "MyProject". It uses the WorkItemTracking client library to build and run a query, and then prints the results to the console. Package library: Microsoft.TeamFoundation.Client().GetProjects().First(p => p.Name == "MyProject"); var store = projectCollection.GetService (); var query = new Query(store, "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.AssignedTo] = @Me AND [System.State] <> 'Closed'"); var result = query.RunQuery(); foreach (WorkItem workItem in result) { Console.WriteLine("ID: {0}, Title: {1}, State: {2}", workItem.Id, workItem.Title, workItem.State); }