Class RelationService
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public class RelationService : RepositoryService, IRelationService, IService
Constructors
View SourceRelationService(ICoreScopeProvider, ILoggerFactory, IEventMessagesFactory, IEntityService, IRelationRepository, IRelationTypeRepository, IAuditRepository)
Declaration
public RelationService(ICoreScopeProvider uowProvider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IEntityService entityService, IRelationRepository relationRepository, IRelationTypeRepository relationTypeRepository, IAuditRepository auditRepository)
Parameters
Type | Name | Description |
---|---|---|
ICore |
uowProvider | |
ILogger |
loggerFactory | |
IEvent |
eventMessagesFactory | |
IEntity |
entityService | |
IRelation |
relationRepository | |
IRelation |
relationTypeRepository | |
IAudit |
auditRepository |
Methods
View SourceAreRelated(Int32, Int32)
Checks whether two items are related
Declaration
public bool AreRelated(int parentId, int childId)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | Id of the Parent relation |
System. |
childId | Id of the Child relation |
Returns
Type | Description |
---|---|
System. |
Returns |
AreRelated(Int32, Int32, String)
Checks whether two items are related
Declaration
public bool AreRelated(int parentId, int childId, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | Id of the Parent relation |
System. |
childId | Id of the Child relation |
System. |
relationTypeAlias | Alias of the type of relation to create |
Returns
Type | Description |
---|---|
System. |
Returns |
AreRelated(Int32, Int32, IRelationType)
Declaration
public bool AreRelated(int parentId, int childId, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | |
System. |
childId | |
IRelation |
relationType |
Returns
Type | Description |
---|---|
System. |
AreRelated(IUmbracoEntity, IUmbracoEntity)
Checks whether two items are related
Declaration
public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent | Parent entity |
IUmbraco |
child | Child entity |
Returns
Type | Description |
---|---|
System. |
Returns |
AreRelated(IUmbracoEntity, IUmbracoEntity, String)
Checks whether two items are related
Declaration
public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent | Parent entity |
IUmbraco |
child | Child entity |
System. |
relationTypeAlias | Alias of the type of relation to create |
Returns
Type | Description |
---|---|
System. |
Returns |
Delete(IRelation)
Deletes a IRelation
Declaration
public void Delete(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to Delete |
Delete(IRelationType)
Deletes a IRelation
Declaration
public void Delete(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelation |
relationType | RelationType to Delete |
DeleteRelationsOfType(IRelationType)
Deletes all IRelation objects based on the passed in IRelation
Declaration
public void DeleteRelationsOfType(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelation |
relationType | IRelation |
GetAllRelations(Int32[])
Gets all IRelation objects
Declaration
public IEnumerable<IRelation> GetAllRelations(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System. |
ids | Optional array of integer ids to return relations for |
Returns
View SourceGetAllRelationsByRelationType(Int32)
Declaration
public IEnumerable<IRelation> GetAllRelationsByRelationType(int relationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System. |
relationTypeId |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetAllRelationsByRelationType(IRelationType)
Declaration
public IEnumerable<IRelation> GetAllRelationsByRelationType(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelation |
relationType |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetAllRelationTypes(Int32[])
Gets all IRelation objects
Declaration
public IEnumerable<IRelationType> GetAllRelationTypes(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System. |
ids | Optional array of integer ids to return relationtypes for |
Returns
Type | Description |
---|---|
IEnumerable<IRelation |
An enumerable list of IRelation objects |
GetByChild(IUmbracoEntity)
Gets a list of IRelation objects by their child Entity
Declaration
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
child | Child Entity to retrieve relations for |
Returns
View SourceGetByChild(IUmbracoEntity, String)
Gets a list of IRelation objects by their child Entity
Declaration
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
child | Child Entity to retrieve relations for |
System. |
relationTypeAlias | Alias of the type of relation to retrieve |
Returns
View SourceGetByChildId(Int32)
Gets a list of IRelation objects by their child Id
Declaration
public IEnumerable<IRelation> GetByChildId(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of the child to retrieve relations for |
Returns
View SourceGetByChildId(Int32, String)
Gets a list of IRelation objects by their child Id
Declaration
public IEnumerable<IRelation> GetByChildId(int id, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of the child to retrieve relations for |
System. |
relationTypeAlias | Alias of the type of relation to retrieve |
Returns
View SourceGetById(Int32)
Gets a IRelation by its Id
Declaration
public IRelation GetById(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of the IRelation |
Returns
View SourceGetByParent(IUmbracoEntity)
Declaration
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetByParent(IUmbracoEntity, String)
Gets a list of IRelation objects by their parent entity
Declaration
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent | Parent Entity to retrieve relations for |
System. |
relationTypeAlias | Alias of the type of relation to retrieve |
Returns
View SourceGetByParentAndChildId(Int32, Int32, IRelationType)
Gets a relation by the unique combination of parentId, childId and relationType.
Declaration
public IRelation GetByParentAndChildId(int parentId, int childId, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | The id of the parent item. |
System. |
childId | The id of the child item. |
IRelation |
relationType | The RelationType. |
Returns
Type | Description |
---|---|
IRelation | The relation or null |
GetByParentId(Int32)
Declaration
public IEnumerable<IRelation> GetByParentId(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetByParentId(Int32, String)
Declaration
public IEnumerable<IRelation> GetByParentId(int id, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | |
System. |
relationTypeAlias |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetByParentOrChildId(Int32)
Gets a list of IRelation objects by their child or parent Id. Using this method will get you all relations regards of it being a child or parent relation.
Declaration
public IEnumerable<IRelation> GetByParentOrChildId(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of the child or parent to retrieve relations for |
Returns
View SourceGetByParentOrChildId(Int32, String)
Declaration
public IEnumerable<IRelation> GetByParentOrChildId(int id, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | |
System. |
relationTypeAlias |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetByRelationTypeAlias(String)
Gets a list of IRelation objects by the Alias of the IRelation
Declaration
public IEnumerable<IRelation> GetByRelationTypeAlias(string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
relationTypeAlias | Alias of the IRelation |
Returns
View SourceGetByRelationTypeId(Int32)
Declaration
public IEnumerable<IRelation> GetByRelationTypeId(int relationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System. |
relationTypeId |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetByRelationTypeName(String)
Gets a list of IRelation objects by the Name of the IRelation
Declaration
public IEnumerable<IRelation> GetByRelationTypeName(string relationTypeName)
Parameters
Type | Name | Description |
---|---|---|
System. |
relationTypeName | Name of the IRelation |
Returns
View SourceGetChildEntitiesFromRelations(IEnumerable<IRelation>)
Gets the Child objects from a list of Relations as a list of IUmbraco
Declaration
public IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IRelation> | relations | List of relations to retrieve child objects from |
Returns
Type | Description |
---|---|
IEnumerable<IUmbraco |
An enumerable list of IUmbraco |
GetChildEntityFromRelation(IRelation)
Gets the Child object from a Relation as an IUmbraco
Declaration
public IUmbracoEntity GetChildEntityFromRelation(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve child object from |
Returns
Type | Description |
---|---|
IUmbraco |
GetEntitiesFromRelation(IRelation)
Gets the Parent and Child objects from a Relation as a
Declaration
public Tuple<IUmbracoEntity, IUmbracoEntity>? GetEntitiesFromRelation(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve parent and child object from |
Returns
Type | Description |
---|---|
System. |
Returns a Tuple with Parent (item1) and Child (item2) |
GetEntitiesFromRelations(IEnumerable<IRelation>)
Gets the Parent and Child objects from a list of Relations as a list of IUmbraco
Declaration
public IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(IEnumerable<IRelation> relations)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IRelation> | relations | List of relations to retrieve parent and child objects from |
Returns
Type | Description |
---|---|
IEnumerable<Tuple<IUmbraco |
An enumerable list of |
GetPagedByRelationTypeId(Int32, Int64, Int32, out Int64, Ordering)
Gets a paged result of IRelation
Declaration
public IEnumerable<IRelation> GetPagedByRelationTypeId(int relationTypeId, long pageIndex, int pageSize, out long totalRecords, Ordering ordering = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
relationTypeId | |
System. |
pageIndex | |
System. |
pageSize | |
System. |
totalRecords | |
Ordering | ordering |
Returns
Type | Description |
---|---|
IEnumerable<IRelation> |
GetPagedChildEntitiesByParentId(Int32, Int64, Int32, out Int64, UmbracoObjectTypes[])
Returns paged child entities for a related parent id
Declaration
public IEnumerable<IUmbracoEntity> GetPagedChildEntitiesByParentId(int id, long pageIndex, int pageSize, out long totalChildren, params UmbracoObjectTypes[] entityTypes)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | |
System. |
pageIndex | |
System. |
pageSize | |
System. |
totalChildren | |
Umbraco |
entityTypes |
Returns
Type | Description |
---|---|
IEnumerable<IUmbraco |
An enumerable list of IUmbraco |
GetPagedParentEntitiesByChildId(Int32, Int64, Int32, out Int64, UmbracoObjectTypes[])
Returns paged parent entities for a related child id
Declaration
public IEnumerable<IUmbracoEntity> GetPagedParentEntitiesByChildId(int id, long pageIndex, int pageSize, out long totalChildren, params UmbracoObjectTypes[] entityTypes)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | |
System. |
pageIndex | |
System. |
pageSize | |
System. |
totalChildren | |
Umbraco |
entityTypes |
Returns
Type | Description |
---|---|
IEnumerable<IUmbraco |
An enumerable list of IUmbraco |
GetParentEntitiesFromRelations(IEnumerable<IRelation>)
Gets the Parent objects from a list of Relations as a list of IUmbraco
Declaration
public IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IRelation> | relations | List of relations to retrieve parent objects from |
Returns
Type | Description |
---|---|
IEnumerable<IUmbraco |
An enumerable list of IUmbraco |
GetParentEntityFromRelation(IRelation)
Gets the Parent object from a Relation as an IUmbraco
Declaration
public IUmbracoEntity GetParentEntityFromRelation(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve parent object from |
Returns
Type | Description |
---|---|
IUmbraco |
GetRelationTypeByAlias(String)
Gets a IRelation
Declaration
public IRelationType GetRelationTypeByAlias(string alias)
Parameters
Type | Name | Description |
---|---|---|
System. |
alias | Alias of the IRelation |
Returns
Type | Description |
---|---|
IRelation |
A IRelation |
GetRelationTypeById(Guid)
Gets a IRelation
Declaration
public IRelationType GetRelationTypeById(Guid id)
Parameters
Type | Name | Description |
---|---|---|
Guid | id | Id of the IRelation |
Returns
Type | Description |
---|---|
IRelation |
A IRelation |
GetRelationTypeById(Int32)
Gets a IRelation
Declaration
public IRelationType GetRelationTypeById(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of the IRelation |
Returns
Type | Description |
---|---|
IRelation |
A IRelation |
HasRelations(IRelationType)
Checks whether any relations exists for the passed in IRelation
Declaration
public bool HasRelations(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelation |
relationType | IRelation |
Returns
Type | Description |
---|---|
System. |
Returns |
IsRelated(Int32)
Checks whether any relations exists for the passed in Id.
Declaration
public bool IsRelated(int id)
Parameters
Type | Name | Description |
---|---|---|
System. |
id | Id of an object to check relations for |
Returns
Type | Description |
---|---|
System. |
Returns |
Relate(Int32, Int32, String)
Relates two objects by their entity Ids.
Declaration
public IRelation Relate(int parentId, int childId, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | Id of the parent |
System. |
childId | Id of the child |
System. |
relationTypeAlias | Alias of the type of relation to create |
Returns
View SourceRelate(Int32, Int32, IRelationType)
Relates two objects by their entity Ids.
Declaration
public IRelation Relate(int parentId, int childId, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
System. |
parentId | Id of the parent |
System. |
childId | Id of the child |
IRelation |
relationType | The type of relation to create |
Returns
View SourceRelate(IUmbracoEntity, IUmbracoEntity, String)
Relates two objects that are based on the IUmbraco
Declaration
public IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent | Parent entity |
IUmbraco |
child | Child entity |
System. |
relationTypeAlias | Alias of the type of relation to create |
Returns
View SourceRelate(IUmbracoEntity, IUmbracoEntity, IRelationType)
Relates two objects that are based on the IUmbraco
Declaration
public IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IUmbraco |
parent | Parent entity |
IUmbraco |
child | Child entity |
IRelation |
relationType | The type of relation to create |
Returns
View SourceSave(IEnumerable<IRelation>)
Declaration
public void Save(IEnumerable<IRelation> relations)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<IRelation> | relations |
Save(IRelation)
Saves a IRelation
Declaration
public void Save(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to save |
Save(IRelationType)
Saves a IRelation
Declaration
public void Save(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelation |
relationType | RelationType to Save |