使用 TFS 中的 WorkItemStore.Query 为参数指定项目列表 [英] Specifying a list of items for the parameters with WorkItemStore.Query in TFS

查看:39
本文介绍了使用 TFS 中的 WorkItemStore.Query 为参数指定项目列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 TFS 项目的 WIQL 查询:

I've got the following WIQL query for a TFS project:

string query = "SELECT * FROM Issue WHERE [System.TeamProject] = @Project "+
                "AND [Assigned To] IN (@AssignedTo)";

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("Project","test");
parameters.Add("AssignedTo","'chris','tfsuser'");
WorkItemStore.Query(query, parameters);

这是通过 .NET TFS API 运行的.

This is being run via the .NET TFS API.

我的问题是 AssignedTo 参数.这意味着如何指定?我已经将它作为 string[]List 以及上面的带引号和不带引号进行了尝试.每个似乎都不起作用.

My problem is with the AssignedTo parameter. How is this meant to be specified? I've tried it as a string[], List<string> as well as with and without quotes as above. Each one doesn't seem to work.

推荐答案

我明白你想做什么,但看起来不太可能.您想要的查询是这样的:

I understand what you're trying to do, but it doesn't look like it's possible. The query that you want is this:

WHERE [System.AssignedTo] in ('John Smith', 'Jane Citizen')

在语义上与此相同:

WHERE [System.AssignedTo] = 'John Smith' OR [System.AssignedTo] = 'Jane Citizen'

我可以弄清楚如何在代码中实现它的唯一方法是将身份指定为单独的参数:

The only way I can work out how to achieve it in code is by specifying the identities as separate parameters:

TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://localhost:8080/tfs/"));
WorkItemStore wis = tfs.GetService<WorkItemStore>();

Dictionary<string, string> values = new Dictionary<string, string>();

values.Add("parameter1", "John Smith");
values.Add("parameter2", "Jane Citizen");

Query query = new Query(wis, "SELECT [System.Id] FROM WorkItems WHERE [System.AssignedTo] IN (@parameter1, @parameter2)", values);

WorkItemCollection workItems = wis.Query(query.QueryString);
WorkItem workItem = workItems[0];

这篇关于使用 TFS 中的 WorkItemStore.Query 为参数指定项目列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆