English 中文(简体)
Specifying a list of items for the parameters with WorkItemStore.Query in TFS
原标题:

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);

This is being run via the .NET TFS API.

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 )

Which is semantically the same as this:

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];
问题回答

Assigned To field is actually [System.AssignedTo]. I don t believe using the display name of the field will work.





相关问题
Why not use TFS as a build / CI solution?

Currently our build solution is set up using TFS + MS Build scripts. TFS is also being used as a CI server. I ve seen several posts on this site telling people about other CI solutions. Are there ...

Get files from TFS under Linux [closed]

is there a free (command line) tool for linux which with I can get all files from a TFS-Repository (no Check in / Check out required - only get actual version)?

upgrading tfs 2008 sp1 to use sql server 2008

I have an instance of tfs 2008 supported by sql server 2005. I want to change the sql server machine by doing a restore based move. I also want to change the version of sql server to 2008. I know ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

TFSReg in 2010 Beta 2?

does anybody know what is the equivalent of the TFSReg.exe command-line tool in 2010 Beta 2? I cannot find it anywhere, I searched the entire Program Files tree. Was it renamed? Moved? Replaced by ...

热门标签