ProjectContext.Projects property
Gets the collection of projects in the Project Web App instance.
Namespace: Microsoft.ProjectServer.Client
Assembly: Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)
Syntax
'Declaration
Public ReadOnly Property Projects As ProjectCollection
Get
'Usage
Dim instance As ProjectContext
Dim value As ProjectCollection
value = instance.Projects
public ProjectCollection Projects { get; }
Property value
Type: Microsoft.ProjectServer.Client.ProjectCollection
A collection of projects.
Remarks
A project entity contains additional entity types, such as tasks, resources, and assignments.
Examples
The following example uses the ProjectContext object to list the published projects in Project Web App. To see the same application using the ProjectServer object, see ProjectContext.Projects. For information about creating a simple CSOM application in Microsoft Visual Studio, see Microsoft.ProjectServer.Client.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;
namespace ReadProjectList
{
class Program
{
private const string pwaPath = "https://ServerName/PwaName/"; // Change the path for Project Web App.
private static ProjectContext projContext;
static void Main(string[] args)
{
projContext = new ProjectContext(pwaPath);
// Get the list of published projects in Project Web App.
projContext.Load(projContext.Projects);
projContext.ExecuteQuery();
Console.WriteLine("\nProject ID : Project name : Created date");
foreach (PublishedProject pubProj in projContext.Projects)
{
Console.WriteLine("\n\t{0}\n\t{1} : {2}", pubProj.Id.ToString(), pubProj.Name,
pubProj.CreatedDate.ToString());
}
Console.Write("\nPress any key to exit: ");
Console.ReadKey(false);
}
}
}