Interface IEntityRepository
Represents a repository for lightweight entity operations.
Namespace: Umbraco.Cms.Core.Persistence.Repositories
Assembly: Umbraco.Core.dll
Syntax
public interface IEntityRepository : IRepository
Methods
View SourceCountByQuery(IQuery<IUmbracoEntity>, IEnumerable<Guid>, IQuery<IUmbracoEntity>?)
Counts entities matching a query for multiple object types.
Declaration
int CountByQuery(IQuery<IUmbracoEntity> query, IEnumerable<Guid> objectTypes, IQuery<IUmbracoEntity>? filter)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
| IEnumerable<Guid> | objectTypes | The object type identifiers. |
| IQuery<IUmbracoEntity> | filter | An optional filter query. |
Returns
| Type | Description |
|---|---|
| int | The count of entities matching the query. |
CountByQuery(IQuery<IUmbracoEntity>, Guid, IQuery<IUmbracoEntity>?)
Counts entities matching a query for a specific object type.
Declaration
int CountByQuery(IQuery<IUmbracoEntity> query, Guid objectType, IQuery<IUmbracoEntity>? filter)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
| Guid | objectType | The object type identifier. |
| IQuery<IUmbracoEntity> | filter | An optional filter query. |
Returns
| Type | Description |
|---|---|
| int | The count of entities matching the query. |
Exists(IEnumerable<Guid>)
Checks whether entities with the specified unique keys exist.
Declaration
bool Exists(IEnumerable<Guid> keys)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | keys | The unique keys of the entities. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exists(Guid)
Checks whether an entity with the specified unique key exists.
Declaration
bool Exists(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the entity. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exists(Guid, Guid)
Asserts if an entity with the given object type exists.
Declaration
bool Exists(Guid key, Guid objectType)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The Key of the entity to find. |
| Guid | objectType | The object type key of the entity. |
Returns
| Type | Description |
|---|---|
| bool | True if an entity with the given key and object type exists. |
Exists(int)
Checks whether an entity with the specified identifier exists.
Declaration
bool Exists(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the entity. |
Returns
| Type | Description |
|---|---|
| bool |
|
Exists(int, Guid)
Asserts if an entity with the given object type exists.
Declaration
bool Exists(int id, Guid objectType)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The id of the entity to find. |
| Guid | objectType | The object type key of the entity. |
Returns
| Type | Description |
|---|---|
| bool | True if an entity with the given id and object type exists. |
Get(Guid)
Gets an entity by its unique key.
Declaration
IEntitySlim? Get(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the entity. |
Returns
| Type | Description |
|---|---|
| IEntitySlim | The entity if found; otherwise, |
Get(Guid, Guid)
Gets an entity by its unique key and object type.
Declaration
IEntitySlim? Get(Guid key, Guid objectTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the entity. |
| Guid | objectTypeId | The object type identifier. |
Returns
| Type | Description |
|---|---|
| IEntitySlim | The entity if found; otherwise, |
Get(int)
Gets an entity by its identifier.
Declaration
IEntitySlim? Get(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the entity. |
Returns
| Type | Description |
|---|---|
| IEntitySlim | The entity if found; otherwise, |
Get(int, Guid)
Gets an entity by its identifier and object type.
Declaration
IEntitySlim? Get(int id, Guid objectTypeId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the entity. |
| Guid | objectTypeId | The object type identifier. |
Returns
| Type | Description |
|---|---|
| IEntitySlim | The entity if found; otherwise, |
GetAll(Guid, params Guid[])
Gets all entities of a specific object type by their unique keys.
Declaration
IEnumerable<IEntitySlim> GetAll(Guid objectType, params Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | objectType | The object type identifier. |
| Guid[] | keys | The unique keys of the entities. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities. |
GetAll(Guid, params int[])
Gets all entities of a specific object type by their identifiers.
Declaration
IEnumerable<IEntitySlim> GetAll(Guid objectType, params int[] ids)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | objectType | The object type identifier. |
| int[] | ids | The identifiers of the entities. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities. |
GetAllPaths(Guid, params Guid[])
Gets all entity paths for a specific object type.
Declaration
IEnumerable<TreeEntityPath> GetAllPaths(Guid objectType, params Guid[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | objectType | The object type identifier. |
| Guid[] | keys | The unique keys to filter the results. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TreeEntityPath> | A collection of entity paths. |
GetAllPaths(Guid, params int[]?)
Gets all entity paths for a specific object type.
Declaration
IEnumerable<TreeEntityPath> GetAllPaths(Guid objectType, params int[]? ids)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | objectType | The object type identifier. |
| int[] | ids | Optional identifiers to filter the results. |
Returns
| Type | Description |
|---|---|
| IEnumerable<TreeEntityPath> | A collection of entity paths. |
GetByQuery(IQuery<IUmbracoEntity>)
Gets entities for a query.
Declaration
IEnumerable<IEntitySlim> GetByQuery(IQuery<IUmbracoEntity> query)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities matching the query. |
GetByQuery(IQuery<IUmbracoEntity>, Guid)
Gets entities for a query and a specific object type, allowing the query to be slightly more optimized.
Declaration
IEnumerable<IEntitySlim> GetByQuery(IQuery<IUmbracoEntity> query, Guid objectType)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
| Guid | objectType | The object type identifier. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities matching the query. |
GetObjectType(Guid)
Gets the object type for an entity by its unique key.
Declaration
UmbracoObjectTypes GetObjectType(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key of the entity. |
Returns
| Type | Description |
|---|---|
| UmbracoObjectTypes | The object type of the entity. |
GetObjectType(int)
Gets the object type for an entity by its identifier.
Declaration
UmbracoObjectTypes GetObjectType(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | The identifier of the entity. |
Returns
| Type | Description |
|---|---|
| UmbracoObjectTypes | The object type of the entity. |
GetPagedResultsByQuery(IQuery<IUmbracoEntity>, ISet<Guid>, long, int, out long, IQuery<IUmbracoEntity>?, Ordering?)
Gets paged entities for a query and multiple object types.
Declaration
IEnumerable<IEntitySlim> GetPagedResultsByQuery(IQuery<IUmbracoEntity> query, ISet<Guid> objectTypes, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity>? filter, Ordering? ordering)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
| ISet<Guid> | objectTypes | The object type identifiers. |
| long | pageIndex | The page index. |
| int | pageSize | The page size. |
| long | totalRecords | Returns the total number of records. |
| IQuery<IUmbracoEntity> | filter | An optional filter query. |
| Ordering | ordering | The ordering to apply, or |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities for the specified page. |
GetPagedResultsByQuery(IQuery<IUmbracoEntity>, Guid, long, int, out long, IQuery<IUmbracoEntity>?, Ordering?)
Gets paged entities for a query and a specific object type.
Declaration
IEnumerable<IEntitySlim> GetPagedResultsByQuery(IQuery<IUmbracoEntity> query, Guid objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity>? filter, Ordering? ordering)
Parameters
| Type | Name | Description |
|---|---|---|
| IQuery<IUmbracoEntity> | query | The query to apply. |
| Guid | objectType | The object type identifier. |
| long | pageIndex | The page index. |
| int | pageSize | The page size. |
| long | totalRecords | Returns the total number of records. |
| IQuery<IUmbracoEntity> | filter | An optional filter query. |
| Ordering | ordering | The ordering to apply, or |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | A collection of entities for the specified page. |
GetSiblings(ISet<Guid>, Guid, int, int, IQuery<IUmbracoEntity>?, Ordering, out long, out long)
Gets sibling entities of a specified target entity, within a given range before and after the target, ordered as specified.
Declaration
IEnumerable<IEntitySlim> GetSiblings(ISet<Guid> objectTypes, Guid targetKey, int before, int after, IQuery<IUmbracoEntity>? filter, Ordering ordering, out long totalBefore, out long totalAfter)
Parameters
| Type | Name | Description |
|---|---|---|
| ISet<Guid> | objectTypes | The object type keys of the entities. |
| Guid | targetKey | The key of the target entity whose siblings are to be retrieved. |
| int | before | The number of siblings to retrieve before the target entity. |
| int | after | The number of siblings to retrieve after the target entity. |
| IQuery<IUmbracoEntity> | filter | An optional filter to apply to the result set. |
| Ordering | ordering | The ordering to apply to the siblings. |
| long | totalBefore | Outputs the total number of siblings before the target entity. |
| long | totalAfter | Outputs the total number of siblings after the target entity. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | Enumerable of sibling entities. |
GetTrashedSiblings(ISet<Guid>, Guid, int, int, IQuery<IUmbracoEntity>?, Ordering, out long, out long)
Gets trashed sibling entities of a specified target entity, within a given range before and after the target, ordered as specified.
Declaration
IEnumerable<IEntitySlim> GetTrashedSiblings(ISet<Guid> objectTypes, Guid targetKey, int before, int after, IQuery<IUmbracoEntity>? filter, Ordering ordering, out long totalBefore, out long totalAfter)
Parameters
| Type | Name | Description |
|---|---|---|
| ISet<Guid> | objectTypes | The object type keys of the entities. |
| Guid | targetKey | The key of the target entity whose siblings are to be retrieved. |
| int | before | The number of siblings to retrieve before the target entity. |
| int | after | The number of siblings to retrieve after the target entity. |
| IQuery<IUmbracoEntity> | filter | An optional filter to apply to the result set. |
| Ordering | ordering | The ordering to apply to the siblings. |
| long | totalBefore | Outputs the total number of siblings before the target entity. |
| long | totalAfter | Outputs the total number of siblings after the target entity. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IEntitySlim> | Enumerable of trashed sibling entities. |
ReserveId(Guid)
Reserves an identifier for a given unique key.
Declaration
int ReserveId(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique key to reserve an identifier for. |
Returns
| Type | Description |
|---|---|
| int | The reserved identifier. |