Class EntityService
Inheritance
System.Object
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class EntityService : ScopeRepositoryService, IService, IEntityService
Constructors
EntityService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IEventMessagesFactory, IContentService, IContentTypeService, IMediaService, IDataTypeService, IMemberService, IMemberTypeService, IdkMap)
Declaration
public EntityService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory, IContentService contentService, IContentTypeService contentTypeService, IMediaService mediaService, IDataTypeService dataTypeService, IMemberService memberService, IMemberTypeService memberTypeService, IdkMap idkMap)
Parameters
Methods
Exists(Guid)
Declaration
public bool Exists(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
Returns
Type |
Description |
System.Boolean |
|
Exists(Int32)
Declaration
public bool Exists(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
|
Returns
Type |
Description |
System.Boolean |
|
Get(Int32, Boolean)
Gets an UmbracoEntity by its Id, and optionally loads the complete object graph.
Declaration
public virtual IUmbracoEntity Get(int id, bool loadBaseType = true)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the object to retrieve
|
System.Boolean |
loadBaseType |
Optional bool to load the complete object graph when set to False .
|
Returns
Get(Int32, UmbracoObjectTypes, Boolean)
Gets an UmbracoEntity by its Id and UmbracoObjectType, and optionally loads the complete object graph.
Declaration
public virtual IUmbracoEntity Get(int id, UmbracoObjectTypes umbracoObjectType, bool loadBaseType = true)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the object to retrieve
|
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the entity to retrieve
|
System.Boolean |
loadBaseType |
Optional bool to load the complete object graph when set to False .
|
Returns
Get<T>(Int32, Boolean)
Gets an UmbracoEntity by its Id and specified Type. Optionally loads the complete object graph.
Declaration
public virtual IUmbracoEntity Get<T>(int id, bool loadBaseType = true)where T : IUmbracoEntity
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the object to retrieve
|
System.Boolean |
loadBaseType |
Optional bool to load the complete object graph when set to False .
|
Returns
Type Parameters
Name |
Description |
T |
Type of the model to retrieve. Must be based on an IUmbracoEntity
|
GetAll(Guid, Int32[])
Declaration
public virtual IEnumerable<IUmbracoEntity> GetAll(Guid objectTypeId, params int[] ids)
Parameters
Type |
Name |
Description |
System.Guid |
objectTypeId |
Guid id of the UmbracoObjectType
|
System.Int32[] |
ids |
|
Returns
GetAll(UmbracoObjectTypes, Guid[])
Declaration
public IEnumerable<IUmbracoEntity> GetAll(UmbracoObjectTypes umbracoObjectType, Guid[] keys)
Parameters
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IUmbracoEntity> |
|
GetAll(UmbracoObjectTypes, Int32[])
Declaration
public virtual IEnumerable<IUmbracoEntity> GetAll(UmbracoObjectTypes umbracoObjectType, params int[] ids)
Parameters
Type |
Name |
Description |
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the entities to return
|
System.Int32[] |
ids |
|
Returns
GetAll<T>(Int32[])
Declaration
public virtual IEnumerable<IUmbracoEntity> GetAll<T>(params int[] ids)where T : IUmbracoEntity
Parameters
Type |
Name |
Description |
System.Int32[] |
ids |
|
Returns
Type Parameters
Name |
Description |
T |
Type of the entities to retrieve
|
GetAllPaths(UmbracoObjectTypes, Guid[])
Declaration
public virtual IEnumerable<EntityPath> GetAllPaths(UmbracoObjectTypes umbracoObjectType, params Guid[] keys)
Parameters
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<EntityPath> |
|
GetAllPaths(UmbracoObjectTypes, Int32[])
Declaration
public virtual IEnumerable<EntityPath> GetAllPaths(UmbracoObjectTypes umbracoObjectType, params int[] ids)
Parameters
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<EntityPath> |
|
GetByKey(Guid, Boolean)
Declaration
public IUmbracoEntity GetByKey(Guid key, bool loadBaseType = true)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
System.Boolean |
loadBaseType |
|
Returns
GetByKey(Guid, UmbracoObjectTypes, Boolean)
Declaration
public IUmbracoEntity GetByKey(Guid key, UmbracoObjectTypes umbracoObjectType, bool loadBaseType = true)
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
UmbracoObjectTypes |
umbracoObjectType |
|
System.Boolean |
loadBaseType |
|
Returns
GetByKey<T>(Guid, Boolean)
Declaration
public IUmbracoEntity GetByKey<T>(Guid key, bool loadBaseType = true)where T : IUmbracoEntity
Parameters
Type |
Name |
Description |
System.Guid |
key |
|
System.Boolean |
loadBaseType |
|
Returns
Type Parameters
GetChildren(Int32)
Gets a collection of children by the parents Id
Declaration
public virtual IEnumerable<IUmbracoEntity> GetChildren(int parentId)
Parameters
Type |
Name |
Description |
System.Int32 |
parentId |
Id of the parent to retrieve children for
|
Returns
GetChildren(Int32, UmbracoObjectTypes)
Gets a collection of children by the parents Id and UmbracoObjectType
Declaration
public virtual IEnumerable<IUmbracoEntity> GetChildren(int parentId, UmbracoObjectTypes umbracoObjectType)
Parameters
Type |
Name |
Description |
System.Int32 |
parentId |
Id of the parent to retrieve children for
|
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the children to retrieve
|
Returns
GetDescendents(Int32)
Gets a collection of descendents by the parents Id
Declaration
public virtual IEnumerable<IUmbracoEntity> GetDescendents(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of entity to retrieve descendents for
|
Returns
GetDescendents(Int32, UmbracoObjectTypes)
Gets a collection of descendents by the parents Id
Declaration
public virtual IEnumerable<IUmbracoEntity> GetDescendents(int id, UmbracoObjectTypes umbracoObjectType)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of entity to retrieve descendents for
|
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the descendents to retrieve
|
Returns
GetEntityType(Int32)
Gets the Type of an entity by its Id
Declaration
public virtual Type GetEntityType(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the entity
|
Returns
Type |
Description |
System.Type |
Type of the entity
|
GetEntityType(UmbracoObjectTypes)
Declaration
public virtual Type GetEntityType(UmbracoObjectTypes umbracoObjectType)
Parameters
Returns
Type |
Description |
System.Type |
Type of the entity
|
GetIdForKey(Guid, UmbracoObjectTypes)
Returns the integer id for a given GUID
Declaration
public Attempt<int> GetIdForKey(Guid key, UmbracoObjectTypes umbracoObjectType)
Parameters
Returns
Type |
Description |
Attempt<System.Int32> |
|
GetIdForUdi(Udi)
Declaration
public Attempt<int> GetIdForUdi(Udi udi)
Parameters
Type |
Name |
Description |
Udi |
udi |
|
Returns
Type |
Description |
Attempt<System.Int32> |
|
GetKeyForId(Int32, UmbracoObjectTypes)
Returns the GUID for a given integer id
Declaration
public Attempt<Guid> GetKeyForId(int id, UmbracoObjectTypes umbracoObjectType)
Parameters
Returns
Type |
Description |
Attempt<System.Guid> |
|
GetObjectType(Guid)
Gets the UmbracoObjectType from the integer id of an IUmbracoEntity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
Unique Id of the entity
|
Returns
GetObjectType(Int32)
Gets the UmbracoObjectType from the integer id of an IUmbracoEntity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the entity
|
Returns
GetObjectType(IUmbracoEntity)
Gets the UmbracoObjectType from an IUmbracoEntity.
Declaration
public virtual UmbracoObjectTypes GetObjectType(IUmbracoEntity entity)
Parameters
Returns
GetPagedChildren(Int32, UmbracoObjectTypes, Int64, Int32, out Int64, String, Direction, String)
Returns a paged collection of children
Declaration
public IEnumerable<IUmbracoEntity> GetPagedChildren(int parentId, UmbracoObjectTypes umbracoObjectType, long pageIndex, int pageSize, out long totalRecords, string orderBy = "SortOrder", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type |
Name |
Description |
System.Int32 |
parentId |
The parent id to return children for
|
UmbracoObjectTypes |
umbracoObjectType |
|
System.Int64 |
pageIndex |
|
System.Int32 |
pageSize |
|
System.Int64 |
totalRecords |
|
System.String |
orderBy |
|
Direction |
orderDirection |
|
System.String |
filter |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IUmbracoEntity> |
|
GetPagedDescendants(IEnumerable<Int32>, UmbracoObjectTypes, Int64, Int32, out Int64, String, Direction, String)
Returns a paged collection of descendants.
Declaration
public IEnumerable<IUmbracoEntity> GetPagedDescendants(IEnumerable<int> ids, UmbracoObjectTypes umbracoObjectType, long pageIndex, int pageSize, out long totalRecords, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Int32> |
ids |
|
UmbracoObjectTypes |
umbracoObjectType |
|
System.Int64 |
pageIndex |
|
System.Int32 |
pageSize |
|
System.Int64 |
totalRecords |
|
System.String |
orderBy |
|
Direction |
orderDirection |
|
System.String |
filter |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IUmbracoEntity> |
|
GetPagedDescendants(Int32, UmbracoObjectTypes, Int64, Int32, out Int64, String, Direction, String)
Returns a paged collection of descendants
Declaration
public IEnumerable<IUmbracoEntity> GetPagedDescendants(int id, UmbracoObjectTypes umbracoObjectType, long pageIndex, int pageSize, out long totalRecords, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "")
Parameters
Type |
Name |
Description |
System.Int32 |
id |
|
UmbracoObjectTypes |
umbracoObjectType |
|
System.Int64 |
pageIndex |
|
System.Int32 |
pageSize |
|
System.Int64 |
totalRecords |
|
System.String |
orderBy |
|
Direction |
orderDirection |
|
System.String |
filter |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IUmbracoEntity> |
|
GetPagedDescendantsFromRoot(UmbracoObjectTypes, Int64, Int32, out Int64, String, Direction, String, Boolean)
Returns a paged collection of descendants from the root
Declaration
public IEnumerable<IUmbracoEntity> GetPagedDescendantsFromRoot(UmbracoObjectTypes umbracoObjectType, long pageIndex, int pageSize, out long totalRecords, string orderBy = "path", Direction orderDirection = Direction.Ascending, string filter = "", bool includeTrashed = true)
Parameters
Type |
Name |
Description |
UmbracoObjectTypes |
umbracoObjectType |
|
System.Int64 |
pageIndex |
|
System.Int32 |
pageSize |
|
System.Int64 |
totalRecords |
|
System.String |
orderBy |
|
Direction |
orderDirection |
|
System.String |
filter |
|
System.Boolean |
includeTrashed |
true/false to include trashed objects
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<IUmbracoEntity> |
|
GetParent(Int32)
Gets the parent of entity by its id
Declaration
public virtual IUmbracoEntity GetParent(int id)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the entity to retrieve the Parent for
|
Returns
GetParent(Int32, UmbracoObjectTypes)
Gets the parent of entity by its id and UmbracoObjectType
Declaration
public virtual IUmbracoEntity GetParent(int id, UmbracoObjectTypes umbracoObjectType)
Parameters
Type |
Name |
Description |
System.Int32 |
id |
Id of the entity to retrieve the Parent for
|
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the parent to retrieve
|
Returns
GetRootEntities(UmbracoObjectTypes)
Gets a collection of the entities at the root, which corresponds to the entities with a Parent Id of -1.
Declaration
public virtual IEnumerable<IUmbracoEntity> GetRootEntities(UmbracoObjectTypes umbracoObjectType)
Parameters
Type |
Name |
Description |
UmbracoObjectTypes |
umbracoObjectType |
UmbracoObjectType of the root entities to retrieve
|
Returns
ReserveId(Guid)
Reserves an identifier for a key.
Declaration
public int ReserveId(Guid key)
Parameters
Type |
Name |
Description |
System.Guid |
key |
They key.
|
Returns
Type |
Description |
System.Int32 |
The identifier.
|