Skip to content
Camilo Galiana edited this page Jan 12, 2016 · 6 revisions

Projects

All the examples will assume that you have created a VSO Context

var context = new VsoContext(account, username, password);

Get a list of team projects

Get the team projects in the account (up to 100 projects)

var projects = await context.Projects.ToListAsync();

Filter by ID

var project = await context.Projects.Where(x => x.Id == "").FirstOrDefaultAsync();

Note that the example uses a "Where" clause to filter and then a "FirstOrDefaultAsync()" to get the first element. This is due the current implementation of "FirstOrDefaultAsync".

Filter by state

var projects = await context.Projects.Where(x => x.State == ProjectState.WellFormed).ToListAsync();

Pagination

var projects = await context.Projects.Skip(5).Take(20).ToListAsync();

Get a project's source control provider

Get a team project's capabilities to see whether it uses Git or TFVC for source control.

var projects = await context.Projects .Where(x => x.Id == projectId) .Include(Project.CapabilitiesKey) .ToListAsync();

Get the project collection

Each team project is in a project collection. Right now, a Visual Studio Team Services account just has one project collection named "DefaultCollection" so you can use that assumption when you call other APIs. You can also look up the collection.

Create a team project

In the current version of Linq2VSO, is it not possible to create data, only consume it