这是我的第一个问题:)
我想知道,是否有类似 WIQL(TFS 工作项查询语言)解析器的东西。我正在处理 TFS 查询,我必须以编程方式更改其中的一些字段。搜索解析或其他东西对我没有任何结果。你能帮助我吗?
注意:我必须自己更改查询。没有任何工作项。
感谢你们。
您可以使用 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);