Class EntityService
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public class EntityService : RepositoryService, IService, IEntityService
Constructors
View SourceEntityService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IIdKeyMap, IEntityRepository)
Declaration
public EntityService(ICoreScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IIdKeyMap idKeyMap, IEntityRepository entityRepository)
Parameters
Type | Name | Description |
---|---|---|
ICoreScopeProvider | provider | |
ILoggerFactory | loggerFactory | |
IEventMessagesFactory | eventMessagesFactory | |
IIdKeyMap | idKeyMap | |
IEntityRepository | entityRepository |
Methods
View SourceExists(Guid)
Determines whether an entity exists.
Declaration
public bool Exists(Guid key)
Parameters
Type | Name | Description |
---|---|---|
Guid | key | The unique key of the entity. |
Returns
Type | Description |
---|---|
System.Boolean |
Exists(Int32)
Determines whether an entity exists.
Declaration
public bool Exists(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
Returns
Type | Description |
---|---|
System.Boolean |
Get(Guid)
Gets an entity.
Declaration
public IEntitySlim Get(Guid key)
Parameters
Type | Name | Description |
---|---|---|
Guid | key | The unique key of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Get(Guid, UmbracoObjectTypes)
Gets an entity.
Declaration
public IEntitySlim Get(Guid key, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
Guid | key | The unique key of the entity. |
UmbracoObjectTypes | objectType | The object type of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Get(Int32)
Gets an entity.
Declaration
public IEntitySlim Get(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Get(Int32, UmbracoObjectTypes)
Gets an entity.
Declaration
public virtual IEntitySlim Get(int id, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
UmbracoObjectTypes | objectType | The object type of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Get<T>(Guid)
Gets an entity.
Declaration
public virtual IEntitySlim Get<T>(Guid key)
where T : IUmbracoEntity
Parameters
Type | Name | Description |
---|---|---|
Guid | key | The unique key of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Type Parameters
Name | Description |
---|---|
T | The type used to determine the object type of the entity. |
Get<T>(Int32)
Gets an entity.
Declaration
public virtual IEntitySlim Get<T>(int id)
where T : IUmbracoEntity
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
Type Parameters
Name | Description |
---|---|
T | The type used to determine the object type of the entity. |
GetAll(Guid)
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll(Guid objectType)
Parameters
Type | Name | Description |
---|---|---|
Guid | objectType | The object type of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetAll(Guid, Guid[])
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll(Guid objectType, params Guid[] keys)
Parameters
Type | Name | Description |
---|---|---|
Guid | objectType | The object type of the entities. |
Guid[] | keys | The unique identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Remarks
If keys
is empty, returns all entities.
GetAll(Guid, Int32[])
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll(Guid objectType, params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
Guid | objectType | The object type of the entities. |
System.Int32[] | ids | The identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Remarks
If ids
is empty, returns all entities.
GetAll(UmbracoObjectTypes)
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll(UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | The object type of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetAll(UmbracoObjectTypes, Guid[])
Gets entities of a given object type.
Declaration
public IEnumerable<IEntitySlim> GetAll(UmbracoObjectTypes objectType, Guid[] keys)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | The object type of the entities. |
Guid[] | keys | The unique identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Remarks
If keys
is empty, returns all entities.
GetAll(UmbracoObjectTypes, Int32[])
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll(UmbracoObjectTypes objectType, params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | The object type of the entities. |
System.Int32[] | ids | The identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Remarks
If ids
is empty, returns all entities.
GetAll<T>()
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll<T>()
where T : IUmbracoEntity
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Type Parameters
Name | Description |
---|---|
T | The type used to determine the object type of the entities. |
GetAll<T>(Guid[])
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll<T>(params Guid[] keys)
where T : IUmbracoEntity
Parameters
Type | Name | Description |
---|---|---|
Guid[] | keys | The unique identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Type Parameters
Name | Description |
---|---|
T | The type used to determine the object type of the entities. |
Remarks
If keys
is empty, returns all entities.
GetAll<T>(Int32[])
Gets entities of a given object type.
Declaration
public virtual IEnumerable<IEntitySlim> GetAll<T>(params int[] ids)
where T : IUmbracoEntity
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | The identifiers of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
Type Parameters
Name | Description |
---|---|
T | The type used to determine the object type of the entities. |
Remarks
If ids
is empty, returns all entities.
GetAllPaths(UmbracoObjectTypes, Guid[])
Gets paths for entities.
Declaration
public virtual IEnumerable<TreeEntityPath> GetAllPaths(UmbracoObjectTypes objectType, params Guid[] keys)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | |
Guid[] | keys |
Returns
Type | Description |
---|---|
IEnumerable<TreeEntityPath> |
GetAllPaths(UmbracoObjectTypes, Int32[])
Gets paths for entities.
Declaration
public virtual IEnumerable<TreeEntityPath> GetAllPaths(UmbracoObjectTypes objectType, params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | |
System.Int32[] | ids |
Returns
Type | Description |
---|---|
IEnumerable<TreeEntityPath> |
GetChildren(Int32)
Gets the children of an entity.
Declaration
public virtual IEnumerable<IEntitySlim> GetChildren(int parentId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetChildren(Int32, UmbracoObjectTypes)
Gets the children of an entity.
Declaration
public virtual IEnumerable<IEntitySlim> GetChildren(int parentId, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | |
UmbracoObjectTypes | objectType | The object type of the children. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetDescendants(Int32)
Gets the descendants of an entity.
Declaration
public virtual IEnumerable<IEntitySlim> GetDescendants(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetDescendants(Int32, UmbracoObjectTypes)
Gets the descendants of an entity.
Declaration
public virtual IEnumerable<IEntitySlim> GetDescendants(int id, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
UmbracoObjectTypes | objectType | The object type of the descendants. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetEntityType(Int32)
Gets the CLR type of an entity.
Declaration
public virtual Type? GetEntityType(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type | Description |
---|---|
System.Nullable<Type> |
GetId(Guid, UmbracoObjectTypes)
Gets the integer identifier corresponding to a unique Guid identifier.
Declaration
public Attempt<int> GetId(Guid key, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
Guid | key | |
UmbracoObjectTypes | objectType |
Returns
Type | Description |
---|---|
Attempt<System.Int32> |
GetId(Udi)
Gets the integer identifier corresponding to a Udi.
Declaration
public Attempt<int> GetId(Udi udi)
Parameters
Type | Name | Description |
---|---|---|
Udi | udi |
Returns
Type | Description |
---|---|
Attempt<System.Int32> |
GetKey(Int32, UmbracoObjectTypes)
Gets the unique Guid identifier corresponding to an integer identifier.
Declaration
public Attempt<Guid> GetKey(int id, UmbracoObjectTypes umbracoObjectType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
UmbracoObjectTypes | umbracoObjectType |
Returns
Type | Description |
---|---|
Attempt<Guid> |
GetObjectType(Guid)
Gets the object type of an entity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(Guid key)
Parameters
Type | Name | Description |
---|---|---|
Guid | key |
Returns
Type | Description |
---|---|
UmbracoObjectTypes |
GetObjectType(Int32)
Gets the object type of an entity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id |
Returns
Type | Description |
---|---|
UmbracoObjectTypes |
GetObjectType(IUmbracoEntity)
Gets the object type of an entity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(IUmbracoEntity entity)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | entity |
Returns
Type | Description |
---|---|
UmbracoObjectTypes |
GetPagedChildren(Int32, UmbracoObjectTypes, Int64, Int32, out Int64, IQuery<IUmbracoEntity>, Ordering)
Gets children of an entity.
Declaration
public IEnumerable<IEntitySlim> GetPagedChildren(int id, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity> filter = null, Ordering ordering = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
UmbracoObjectTypes | objectType | |
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
IQuery<IUmbracoEntity> | filter | |
Ordering | ordering |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetPagedDescendants(IEnumerable<Int32>, UmbracoObjectTypes, Int64, Int32, out Int64, IQuery<IUmbracoEntity>, Ordering)
Gets descendants of entities.
Declaration
public IEnumerable<IEntitySlim> GetPagedDescendants(IEnumerable<int> ids, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity> filter = null, Ordering ordering = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.Int32> | ids | |
UmbracoObjectTypes | objectType | |
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
IQuery<IUmbracoEntity> | filter | |
Ordering | ordering |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetPagedDescendants(Int32, UmbracoObjectTypes, Int64, Int32, out Int64, IQuery<IUmbracoEntity>, Ordering)
Gets descendants of an entity.
Declaration
public IEnumerable<IEntitySlim> GetPagedDescendants(int id, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity> filter = null, Ordering ordering = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
UmbracoObjectTypes | objectType | |
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
IQuery<IUmbracoEntity> | filter | |
Ordering | ordering |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetPagedDescendants(UmbracoObjectTypes, Int64, Int32, out Int64, IQuery<IUmbracoEntity>, Ordering, Boolean)
Gets descendants of root.
Declaration
public IEnumerable<IEntitySlim> GetPagedDescendants(UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity> filter = null, Ordering ordering = null, bool includeTrashed = true)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | |
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
IQuery<IUmbracoEntity> | filter | |
Ordering | ordering | |
System.Boolean | includeTrashed |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetPagedTrashedChildren(Int32, UmbracoObjectTypes, Int64, Int32, out Int64, IQuery<IUmbracoEntity>, Ordering)
Gets children of an entity.
Declaration
public IEnumerable<IEntitySlim> GetPagedTrashedChildren(int id, UmbracoObjectTypes objectType, long pageIndex, int pageSize, out long totalRecords, IQuery<IUmbracoEntity> filter = null, Ordering ordering = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
UmbracoObjectTypes | objectType | |
System.Int64 | pageIndex | |
System.Int32 | pageSize | |
System.Int64 | totalRecords | |
IQuery<IUmbracoEntity> | filter | |
Ordering | ordering |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
GetParent(Int32)
Gets the parent of an entity.
Declaration
public virtual IEntitySlim GetParent(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
Returns
Type | Description |
---|---|
IEntitySlim |
GetParent(Int32, UmbracoObjectTypes)
Gets the parent of an entity.
Declaration
public virtual IEntitySlim GetParent(int id, UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The identifier of the entity. |
UmbracoObjectTypes | objectType | The object type of the parent. |
Returns
Type | Description |
---|---|
IEntitySlim |
GetRootEntities(UmbracoObjectTypes)
Gets entities at root.
Declaration
public virtual IEnumerable<IEntitySlim> GetRootEntities(UmbracoObjectTypes objectType)
Parameters
Type | Name | Description |
---|---|---|
UmbracoObjectTypes | objectType | The object type of the entities. |
Returns
Type | Description |
---|---|
IEnumerable<IEntitySlim> |
ReserveId(Guid)
Reserves an identifier for a key.
Declaration
public int ReserveId(Guid key)
Parameters
Type | Name | Description |
---|---|---|
Guid | key | They key. |
Returns
Type | Description |
---|---|
System.Int32 | The identifier. |
Remarks
When a new content or a media is saved with the key, it will have the reserved identifier.