November Happy Hour will be moved to Thursday December 5th.

Class ProjectRepository

Repository for loading and save Project and ProjectItem

Inheritance
System.Object
ProjectRepository
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 9.12.2
Syntax
public abstract class ProjectRepository

Constructors

ProjectRepository()

Declaration
protected ProjectRepository()

Methods

Delete(Int32)

Deletes the Project with the specified identifyer

Declaration
public abstract void Delete(int id)
Parameters
Type Name Description
System.Int32 id

The identifier of the project that should be deleted.

DeleteItems(IEnumerable<Int32>)

Deletes the ProjectItem with the provided identifiers from a project.

Declaration
public abstract void DeleteItems(IEnumerable<int> projectItems)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Int32> projectItems

A list of project item identity

Get(Int32)

Gets a Project by it's identifier

Declaration
public abstract Project Get(int id)
Parameters
Type Name Description
System.Int32 id

The id of the project to be retrieved

Returns
Type Description
Project

The project or null if it was not found

GetItem(Int32)

Load a single project item

Declaration
public abstract ProjectItem GetItem(int id)
Parameters
Type Name Description
System.Int32 id

The project item id

Returns
Type Description
ProjectItem

The project item or if no project item was found null

GetItems(IEnumerable<ContentReference>)

Gets all ProjectItem that matches the provided ContentReference list.

Declaration
public abstract IEnumerable<ProjectItem> GetItems(IEnumerable<ContentReference> contentReferences)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ContentReference> contentReferences
Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

Items of ProjectItem that matches the ContentReference list.

Remarks

The result of the GetItems or the number of items may be different from ContentReference. If the ContentReference has no WorkID then returns all ProjectItem that match the ContentReference

GetItems(Int32)

Declaration
[Obsolete("This method have been replaced with ListItems")]
public virtual IEnumerable<ProjectItem> GetItems(int id)
Parameters
Type Name Description
System.Int32 id
Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

GetItems(Int32, String, CultureInfo, Int32, Int32, out Int32)

Declaration
[Obsolete("This method have been replaced with ListItems")]
public virtual IEnumerable<ProjectItem> GetItems(int id, string category, CultureInfo cultureInfo, int startIndex, int maxRows, out int totalCount)
Parameters
Type Name Description
System.Int32 id
System.String category
System.Globalization.CultureInfo cultureInfo
System.Int32 startIndex
System.Int32 maxRows
System.Int32 totalCount
Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

List()

Lists all Project in the repository.

Declaration
public virtual IEnumerable<Project> List()
Returns
Type Description
System.Collections.Generic.IEnumerable<Project>

A list of projects, if no projects was found an empty list will be returned

List(Int32, Int32, out Int32)

Lists all Project in the repository.

Declaration
public virtual IEnumerable<Project> List(int startIndex, int maxRows, out int totalCount)
Parameters
Type Name Description
System.Int32 startIndex

The start index, used for paging

System.Int32 maxRows

The maximum number of rows returned

System.Int32 totalCount

The total amount of projects

Returns
Type Description
System.Collections.Generic.IEnumerable<Project>

A list of projects, if no projects was found an empty list will be returned

List(Nullable<ProjectStatus>, Int32, Int32, out Int32)

Lists all Project in the repository with the specified status.

Declaration
public abstract IEnumerable<Project> List(ProjectStatus? status, int startIndex, int maxRows, out int totalCount)
Parameters
Type Name Description
System.Nullable<ProjectStatus> status

The status of projects to get or null to get all projects regardless of status.

System.Int32 startIndex

The start index, used for paging

System.Int32 maxRows

The maximum number of rows returned

System.Int32 totalCount

The total amount of projects

Returns
Type Description
System.Collections.Generic.IEnumerable<Project>

A list of projects, if no projects was found an empty list will be returned

ListItems(Int32)

Gets all ProjectItem that are linked to a project

Declaration
public virtual IEnumerable<ProjectItem> ListItems(int id)
Parameters
Type Name Description
System.Int32 id

The project id

Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

A list of project items, if no project items was found an empty list will be returned

ListItems(Int32, CultureInfo, Int32, Int32, out Int32)

Gets all ProjectItem that are linked to a project

Declaration
public IEnumerable<ProjectItem> ListItems(int id, CultureInfo language, int startIndex, int maxRows, out int totalCount)
Parameters
Type Name Description
System.Int32 id

The project id

System.Globalization.CultureInfo language

The language of the items to return (optional)

System.Int32 startIndex

The start index, used for paging

System.Int32 maxRows

The maximum number of rows returned

System.Int32 totalCount

The total number of items in the set

Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

A list of project items, if no project items was found an empty list will be returned

ListItems(Int32, String, CultureInfo, Int32, Int32, out Int32)

Gets all ProjectItem that are linked to a project

Declaration
public abstract IEnumerable<ProjectItem> ListItems(int id, string category, CultureInfo language, int startIndex, int maxRows, out int totalCount)
Parameters
Type Name Description
System.Int32 id

The project id

System.String category

The category of the items to return (optional)

System.Globalization.CultureInfo language

The language of the items to return (optional)

System.Int32 startIndex

The start index, used for paging

System.Int32 maxRows

The maximum number of rows returned

System.Int32 totalCount

The total number of items in the set

Returns
Type Description
System.Collections.Generic.IEnumerable<ProjectItem>

A list of project items, if no project items was found an empty list will be returned

OnProjectDeleted(ProjectEventArgs)

Raises the ProjectDeleted event.

Declaration
protected virtual void OnProjectDeleted(ProjectEventArgs args)
Parameters
Type Name Description
ProjectEventArgs args

The ProjectEventArgs instance containing the event data.

OnProjectItemsDeleted(ProjectItemsEventArgs)

Raises the ProjectItemsDeleted event.

Declaration
protected virtual void OnProjectItemsDeleted(ProjectItemsEventArgs args)
Parameters
Type Name Description
ProjectItemsEventArgs args

The ProjectItemsEventArgs instance containing the event data.

OnProjectItemsSaved(ProjectItemsEventArgs)

Raises the ProjectItemsSaved event.

Declaration
protected virtual void OnProjectItemsSaved(ProjectItemsEventArgs args)
Parameters
Type Name Description
ProjectItemsEventArgs args

The ProjectItemsEventArgs instance containing the event data.

OnProjectSaved(ProjectEventArgs)

Raises the ProjectSaved event.

Declaration
protected virtual void OnProjectSaved(ProjectEventArgs args)
Parameters
Type Name Description
ProjectEventArgs args

The ProjectEventArgs instance containing the event data.

Save(Project)

Creates or saves a Project

Declaration
public abstract void Save(Project project)
Parameters
Type Name Description
Project project

The project to save

SaveItems(IEnumerable<ProjectItem>)

Saves a list of ProjectItem to a project

Declaration
public abstract void SaveItems(IEnumerable<ProjectItem> projectItems)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ProjectItem> projectItems

A list of project items

Remarks

Projects that are in status Published will automatically get status Active

Events

ProjectDeleted

Occurs when a Project has been deleted.

Declaration
public static event EventHandler<ProjectEventArgs> ProjectDeleted
Event Type
Type Description
System.EventHandler<ProjectEventArgs>

ProjectItemsDeleted

Occurs when list of ProjectItem has been deleted.

Declaration
public static event EventHandler<ProjectItemsEventArgs> ProjectItemsDeleted
Event Type
Type Description
System.EventHandler<ProjectItemsEventArgs>

ProjectItemsSaved

Occurs when list of ProjectItem has been saved, i.e. created or updated.

Declaration
public static event EventHandler<ProjectItemsEventArgs> ProjectItemsSaved
Event Type
Type Description
System.EventHandler<ProjectItemsEventArgs>

ProjectSaved

Occurs when a Project has been saved, i.e. created or updated.

Declaration
public static event EventHandler<ProjectEventArgs> ProjectSaved
Event Type
Type Description
System.EventHandler<ProjectEventArgs>

Extension Methods