Reputation: 2132
Similar to this, I want to get all projects listed under a user. I'm currently working with the code from the link before:
private static List<string> GetTfsProjects(Uri tpcAddress)
{
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcAddress);
tpc.Authenticate();
var workItemStore = new WorkItemStore(tpc);
var projectList = (from Project pr in workItemStore.Projects select pr.Name).ToList();
return projectList;
}
..but it's only returning "LSWebsite" (my URI is h ttp://server:port/defaultcollection
). How do I get LSWebsite and its children? Image below shows the hierarchy I'm currently working with.
Upvotes: 2
Views: 532
Reputation: 52808
Those look like teams.
Try this snippet:
var teamService = tpc.GetService<TfsTeamService>();
var teams =
projectList
.SelectMany(
projectId =>
teamService
.QueryTeams(projectId)
.Select(t => String.Format("{0}\\{1}", projectId, t.Name)))
.ToArray();
projectList.AddRange(teams);
Taken from Shai's blog here.
Upvotes: 2