Search code examples
tfswiql

Is there a way to save a WIQL query on the TFS Server?


Hopefully the title says it all. I've retrieved the results of adhoc queries using the WorkItemStore.Query() method and created Query objects via the new syntax. However after examining the object model for Query objects, QueryFolders, QueryItems and the WorkItemStore I can't find a way to create and save a WIQL query to the store/TFS Server.

Any suggestions?


Solution

  • You can use QueryHierarchy.Save Method to save the query. For example:

    QueryDefinition query = new QueryDefinition("My Query", "Select * from WorkItems Where [System.AssignedTo] = @me", parentFolder); 
    myproject.QueryHierarchy.Save();
    

    Check blog for more information: http://blogs.msdn.com/b/team_foundation/archive/2010/06/16/work-item-tracking-queries-object-model-in-2010.aspx