ProjectCollection class

Represents a collection of PublishedProject objects.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<PublishedProject>
        Microsoft.ProjectServer.Client.ProjectCollection

Namespace:  Microsoft.ProjectServer.Client
Assembly:  Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)

Syntax

'Declaration
<ScriptTypeAttribute("PS.ProjectCollection", ServerTypeId := "{8d842010-5471-4748-ab8a-ed6df0494f3d}")> _
Public Class ProjectCollection _
    Inherits ClientObjectCollection(Of PublishedProject)
'Usage
Dim instance As ProjectCollection
[ScriptTypeAttribute("PS.ProjectCollection", ServerTypeId = "{8d842010-5471-4748-ab8a-ed6df0494f3d}")]
public class ProjectCollection : ClientObjectCollection<PublishedProject>

Remarks

To check out a published project for editing, use the PublishedProjectCheckOut() method.

Project Server creates a virtual PublishedProject object for each draft project that has not yet been published. A virtual published project ensures that a draft project can be retrieved through the ProjectCollection object, whether it has been published or not. A retrieved project gets properties from the draft tables in the Project database.

For example, if you create a draft project with the PSI, and then read all projects with the CSOM, the ProjectCollection object contains the unpublished draft project. You can determine whether a project has been published by the value of the PublishedProject.LastPublishedDate property, which is inherited from Project.LastPublishedDate. For an unpublished project, the LastPublishedDate property value is DateTime.Min (1/1/0001). The following CSOM code fragment creates a draft project but does not persist or publish it.

ProjectContext projContext = new ProjectContext("http://ServerName/pwa");
ProjectCreationInformation newProj = new ProjectCreationInformation();

newProj.Id = Guid.NewGuid();
newProj.Name = "Test project not published";
newProj.Start = DateTime.Today.Date;

PublishedProject newPublishedProj = projContext.Projects.Add(newProj);

projContext.Load(newPublishedProj);
projContext.ExecuteQuery();

DateTime pubDate = newPublishedProj.LastPublishedDate;
Console.Write("\n\tLastPublishedDate before publishing: {0}", pubDate.ToString());

Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also

Reference

ProjectCollection members

Microsoft.ProjectServer.Client namespace

Project

ProjectCreationInformation

DraftProject

PublishedProject

Projects