这是我的第一个问题:)
我想知道,如果有类似WIQL(TFS工作项查询语言)解析器的东西。 我正在处理TFS查询,我必须以编程方式更改它们的某些字段。搜索解析或某些内容对我没有任何意义。你能救我吗?
注意:我必须自己更改查询。没有任何工作项目。
谢谢你们。
答案 0 :(得分:0)
您可以使用REST api或.net api:
POST https://{instance}/defaultcollection/[{project}/]_apis/wit/wiql?api-version={version}
Content-type: Application/json
{
"query": string
}
// credentials if required
System.Net.ICredentials credentials = new System.Net.NetworkCredential("User", "Password", "Domain");
// create the collection
Microsoft.TeamFoundation.Client.TfsTeamProjectCollection teamProjectCollection =
new Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(new Uri(@"http://tfsServer:8080/tfs/collection"), credentials);
// check we are authenticated
teamProjectCollection.EnsureAuthenticated();
// create the work item store
Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore Store =
(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore)
teamProjectCollection.GetService(typeof(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore));
// create a query to select tasks
string query = "SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Task' AND [System.IterationPath] = '@IterationPath' ORDER BY [System.WorkItemType], [System.Id]";
// replace the iteration
query = query.Replace("@IterationPath", "IterationPath");
// query the store!
Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection WIC = Store.Query(query);