Interface IContentRepository<TId, TEntity>
Defines the base implementation of a repository for content items.
Namespace: Umbraco.Cms.Core.Persistence.Repositories
Assembly: Umbraco.Core.dll
Syntax
public interface IContentRepository<in TId, TEntity> : IReadWriteQueryRepository<TId, TEntity>, IReadRepository<TId, TEntity>, IWriteRepository<TEntity>, IQueryRepository<TEntity>, IRepository where TEntity : IUmbracoEntity
Type Parameters
| Name | Description |
|---|---|
| TId | |
| TEntity |
Properties
View SourceRecycleBinId
Gets the recycle bin identifier.
Declaration
int RecycleBinId { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceCheckDataIntegrity(ContentDataIntegrityReportOptions)
Checks the data integrity of content items.
Declaration
ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentDataIntegrityReportOptions | options | The options for the data integrity check. |
Returns
| Type | Description |
|---|---|
| ContentDataIntegrityReport | A report containing the results of the integrity check. |
Count(string?)
Gets the count of content items of a given content type.
Declaration
int Count(string? contentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contentTypeAlias |
Returns
| Type | Description |
|---|---|
| int |
CountChildren(int, string?)
Gets the count of child content items of a given parent content, of a given content type.
Declaration
int CountChildren(int parentId, string? contentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | |
| string | contentTypeAlias |
Returns
| Type | Description |
|---|---|
| int |
CountDescendants(int, string?)
Gets the count of descendant content items of a given parent content, of a given content type.
Declaration
int CountDescendants(int parentId, string? contentTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | |
| string | contentTypeAlias |
Returns
| Type | Description |
|---|---|
| int |
DeleteVersion(int)
Deletes a version.
Declaration
void DeleteVersion(int versionId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | versionId |
DeleteVersions(int, DateTime)
Deletes all versions older than a date.
Declaration
void DeleteVersions(int nodeId, DateTime versionDate)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeId | |
| DateTime | versionDate |
GetAllVersions(int)
Gets versions.
Declaration
IEnumerable<TEntity> GetAllVersions(int nodeId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeId |
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> |
Remarks
Current version is first, and then versions are ordered with most recent first.
GetAllVersionsSlim(int, int, int)
Gets versions.
Declaration
IEnumerable<TEntity> GetAllVersionsSlim(int nodeId, int skip, int take)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nodeId | |
| int | skip | |
| int | take |
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> |
Remarks
Current version is first, and then versions are ordered with most recent first.
GetPage(IQuery<TEntity>?, long, int, out long, string[]?, IQuery<TEntity>?, Ordering?)
Gets paged content items.
Declaration
IEnumerable<TEntity> GetPage(IQuery<TEntity>? query, long pageIndex, int pageSize, out long totalRecords, string[]? propertyAliases, IQuery<TEntity>? filter, Ordering? ordering)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<TEntity> | query | The base query for content items. |
| long | pageIndex | The page index (zero-based). |
| int | pageSize | The number of items per page. |
| long | totalRecords | Output parameter with total record count. |
| string[] | propertyAliases | Optional array of property aliases to load. If null, all properties are loaded. If empty array, no custom properties are loaded (only system properties). |
| IQuery<TEntity> | filter | Optional filter query. |
| Ordering | ordering | The ordering specification. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> | A collection of content items for the specified page. |
Remarks
Here, filter can be null but ordering cannot.
GetPage(IQuery<TEntity>?, long, int, out long, IQuery<TEntity>?, Ordering?)
Gets paged content items.
Declaration
[Obsolete("Please use the method overload with all parameters. Scheduled for removal in Umbraco 19.")]
IEnumerable<TEntity> GetPage(IQuery<TEntity>? query, long pageIndex, int pageSize, out long totalRecords, IQuery<TEntity>? filter, Ordering? ordering)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<TEntity> | query | |
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| IQuery<TEntity> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> |
Remarks
Here, filter can be null but ordering cannot.
GetRecycleBin()
Gets the recycle bin content.
Declaration
IEnumerable<TEntity> GetRecycleBin()
Returns
| Type | Description |
|---|---|
| IEnumerable<TEntity> |
GetVersion(int)
Gets a version.
Declaration
TEntity? GetVersion(int versionId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | versionId |
Returns
| Type | Description |
|---|---|
| TEntity |
GetVersionIds(int, int)
Gets version identifiers.
Declaration
IEnumerable<int> GetVersionIds(int id, int topRows)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | |
| int | topRows |
Returns
| Type | Description |
|---|---|
| IEnumerable<int> |
Remarks
Current version is first, and then versions are ordered with most recent first.