Class RelationService
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
public class RelationService : ScopeRepositoryService, IRelationService, IService
Constructors
RelationService(IDatabaseUnitOfWorkProvider, RepositoryFactory, ILogger, IEventMessagesFactory, IEntityService)
Declaration
public RelationService(IDatabaseUnitOfWorkProvider uowProvider, RepositoryFactory repositoryFactory, ILogger logger, IEventMessagesFactory eventMessagesFactory, IEntityService entityService)
Parameters
Type | Name | Description |
---|---|---|
IDatabaseUnitOfWorkProvider | uowProvider | |
RepositoryFactory | repositoryFactory | |
ILogger | logger | |
IEventMessagesFactory | eventMessagesFactory | |
IEntityService | entityService |
Methods
AreRelated(Int32, Int32)
Checks whether two items are related
Declaration
public bool AreRelated(int parentId, int childId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | Id of the Parent relation |
System.Int32 | childId | Id of the Child relation |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
AreRelated(Int32, Int32, String)
Checks whether two items are related with a given relation type alias
Declaration
public bool AreRelated(int parentId, int childId, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | Id of the Parent relation |
System.Int32 | childId | Id of the Child relation |
System.String | relationTypeAlias | Alias of the relation type |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
AreRelated(Int32, Int32, IRelationType)
Checks whether two items are related with a given relation type
Declaration
public bool AreRelated(int parentId, int childId, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId | Id of the Parent relation |
System.Int32 | childId | Id of the Child relation |
IRelationType | relationType | Type of relation |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
AreRelated(IUmbracoEntity, IUmbracoEntity)
Checks whether two items are related
Declaration
public bool AreRelated(IUmbracoEntity parent, IUmbracoEntity child)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | parent | Parent entity |
IUmbracoEntity | child | Child entity |
Returns
Type | Description |
---|---|
System.Boolean | 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 |
---|---|---|
IUmbracoEntity | parent | Parent entity |
IUmbracoEntity | child | Child entity |
System.String | relationTypeAlias | Alias of the type of relation to create |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
Delete(IRelation)
Deletes a Relation
Declaration
public void Delete(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to Delete |
Delete(IRelationType)
Deletes a RelationType
Declaration
public void Delete(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelationType | relationType | RelationType to Delete |
DeleteRelationsOfType(IRelationType)
Deletes all Relation objects based on the passed in RelationType
Declaration
public void DeleteRelationsOfType(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelationType | relationType | RelationType to Delete Relations for |
GetAllRelations(Int32[])
Gets all Relation objects
Declaration
public IEnumerable<IRelation> GetAllRelations(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | Optional array of integer ids to return relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetAllRelationsByRelationType(Int32)
Gets all Relation objects by their RelationType's Id
Declaration
public IEnumerable<IRelation> GetAllRelationsByRelationType(int relationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | relationTypeId | Id of the RelationType to retrieve Relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetAllRelationsByRelationType(RelationType)
Gets all Relation objects by their RelationType
Declaration
public IEnumerable<IRelation> GetAllRelationsByRelationType(RelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
RelationType | relationType | RelationType to retrieve Relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetAllRelationTypes(Int32[])
Gets all Relation objects
Declaration
public IEnumerable<IRelationType> GetAllRelationTypes(params int[] ids)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | ids | Optional array of integer ids to return relationtypes for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelationType> | An enumerable list of RelationType objects |
GetByChild(IUmbracoEntity)
Gets a list of Relation objects by their child Entity
Declaration
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | child | Child Entity to retrieve relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByChild(IUmbracoEntity, String)
Gets a list of Relation objects by their child Entity
Declaration
public IEnumerable<IRelation> GetByChild(IUmbracoEntity child, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | child | Child Entity to retrieve relations for |
System.String | relationTypeAlias | Alias of the type of relation to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByChildId(Int32)
Gets a list of Relation objects by their child Id
Declaration
public IEnumerable<IRelation> GetByChildId(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the child to retrieve relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetById(Int32)
Gets a Relation by its Id
Declaration
public IRelation GetById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the Relation |
Returns
Type | Description |
---|---|
IRelation | A Relation object |
GetByParent(IUmbracoEntity)
Gets a list of Relation objects by their parent entity
Declaration
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | parent | Parent Entity to retrieve relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByParent(IUmbracoEntity, String)
Gets a list of Relation objects by their parent entity
Declaration
public IEnumerable<IRelation> GetByParent(IUmbracoEntity parent, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | parent | Parent Entity to retrieve relations for |
System.String | relationTypeAlias | Alias of the type of relation to retrieve |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByParentId(Int32)
Gets a list of Relation objects by their parent Id
Declaration
public IEnumerable<IRelation> GetByParentId(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the parent to retrieve relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByParentOrChildId(Int32)
Gets a list of Relation 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.Int32 | id | Id of the child or parent to retrieve relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByParentOrChildId(Int32, String)
Declaration
public IEnumerable<IRelation> GetByParentOrChildId(int id, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | |
System.String | relationTypeAlias |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> |
GetByRelationTypeAlias(String)
Gets a list of Relation objects by the Alias of the RelationType
Declaration
public IEnumerable<IRelation> GetByRelationTypeAlias(string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | relationTypeAlias | Alias of the RelationType to retrieve Relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByRelationTypeId(Int32)
Gets a list of Relation objects by the Id of the RelationType
Declaration
public IEnumerable<IRelation> GetByRelationTypeId(int relationTypeId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | relationTypeId | Id of the RelationType to retrieve Relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetByRelationTypeName(String)
Gets a list of Relation objects by the Name of the RelationType
Declaration
public IEnumerable<IRelation> GetByRelationTypeName(string relationTypeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | relationTypeName | Name of the RelationType to retrieve Relations for |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IRelation> | An enumerable list of Relation objects |
GetChildEntitiesFromRelations(IEnumerable<IRelation>, Boolean)
Gets the Child objects from a list of Relations as a list of IUmbracoEntity objects.
Declaration
public IEnumerable<IUmbracoEntity> GetChildEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IRelation> | relations | List of relations to retrieve child objects from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IUmbracoEntity> | An enumerable list of IUmbracoEntity |
GetChildEntityFromRelation(IRelation, Boolean)
Gets the Child object from a Relation as an IUmbracoEntity
Declaration
public IUmbracoEntity GetChildEntityFromRelation(IRelation relation, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve child object from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
IUmbracoEntity |
GetEntitiesFromRelation(IRelation, Boolean)
Gets the Parent and Child objects from a Relation as a System.Tuple"/> with IUmbracoEntity.
Declaration
public Tuple<IUmbracoEntity, IUmbracoEntity> GetEntitiesFromRelation(IRelation relation, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve parent and child object from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
System.Tuple<IUmbracoEntity, IUmbracoEntity> | Returns a Tuple with Parent (item1) and Child (item2) |
GetEntitiesFromRelations(IEnumerable<IRelation>, Boolean)
Gets the Parent and Child objects from a list of Relations as a list of IUmbracoEntity objects.
Declaration
public IEnumerable<Tuple<IUmbracoEntity, IUmbracoEntity>> GetEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IRelation> | relations | List of relations to retrieve parent and child objects from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Tuple<IUmbracoEntity, IUmbracoEntity>> | An enumerable list of System.Tuple with IUmbracoEntity |
GetParentEntitiesFromRelations(IEnumerable<IRelation>, Boolean)
Gets the Parent objects from a list of Relations as a list of IUmbracoEntity objects.
Declaration
public IEnumerable<IUmbracoEntity> GetParentEntitiesFromRelations(IEnumerable<IRelation> relations, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IRelation> | relations | List of relations to retrieve parent objects from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IUmbracoEntity> | An enumerable list of IUmbracoEntity |
GetParentEntityFromRelation(IRelation, Boolean)
Gets the Parent object from a Relation as an IUmbracoEntity
Declaration
public IUmbracoEntity GetParentEntityFromRelation(IRelation relation, bool loadBaseType = false)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to retrieve parent object from |
System.Boolean | loadBaseType | Optional bool to load the complete object graph when set to |
Returns
Type | Description |
---|---|
IUmbracoEntity |
GetRelationTypeByAlias(String)
Gets a RelationType by its Alias
Declaration
public IRelationType GetRelationTypeByAlias(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | Alias of the RelationType |
Returns
Type | Description |
---|---|
IRelationType | A RelationType object |
GetRelationTypeById(Guid)
Gets a RelationType by its Id
Declaration
public IRelationType GetRelationTypeById(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Id of the RelationType |
Returns
Type | Description |
---|---|
IRelationType | A RelationType object |
GetRelationTypeById(Int32)
Gets a RelationType by its Id
Declaration
public IRelationType GetRelationTypeById(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of the RelationType |
Returns
Type | Description |
---|---|
IRelationType | A RelationType object |
HasRelations(IRelationType)
Checks whether any relations exists for the passed in RelationType.
Declaration
public bool HasRelations(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelationType | relationType | RelationType to check for relations |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
IsRelated(Int32)
Checks whether any relations exists for the passed in Id.
Declaration
public bool IsRelated(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | Id of an object to check relations for |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
Relate(IUmbracoEntity, IUmbracoEntity, String)
Relates two objects that are based on the IUmbracoEntity interface.
Declaration
public IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, string relationTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | parent | Parent entity |
IUmbracoEntity | child | Child entity |
System.String | relationTypeAlias | Alias of the type of relation to create |
Returns
Type | Description |
---|---|
IRelation | The created Relation |
Relate(IUmbracoEntity, IUmbracoEntity, IRelationType)
Relates two objects that are based on the IUmbracoEntity interface.
Declaration
public IRelation Relate(IUmbracoEntity parent, IUmbracoEntity child, IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoEntity | parent | Parent entity |
IUmbracoEntity | child | Child entity |
IRelationType | relationType | The type of relation to create |
Returns
Type | Description |
---|---|
IRelation | The created Relation |
Save(IRelation)
Saves a Relation
Declaration
public void Save(IRelation relation)
Parameters
Type | Name | Description |
---|---|---|
IRelation | relation | Relation to save |
Save(IRelationType)
Saves a RelationType
Declaration
public void Save(IRelationType relationType)
Parameters
Type | Name | Description |
---|---|---|
IRelationType | relationType | RelationType to Save |
Events
DeletedRelation
Occurs after a Relation is Deleted
Declaration
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> DeletedRelation
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> |
DeletedRelationType
Occurs after a RelationType is Deleted
Declaration
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> DeletedRelationType
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> |
DeletingRelation
Occurs before Deleting a Relation
Declaration
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> DeletingRelation
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, DeleteEventArgs<IRelation>> |
DeletingRelationType
Occurs before Deleting a RelationType
Declaration
public static event TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> DeletingRelationType
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, DeleteEventArgs<IRelationType>> |
SavedRelation
Occurs after a Relation is Saved
Declaration
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> SavedRelation
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> |
SavedRelationType
Occurs after a RelationType is Saved
Declaration
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> SavedRelationType
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> |
SavingRelation
Occurs before Saving a Relation
Declaration
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> SavingRelation
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, SaveEventArgs<IRelation>> |
SavingRelationType
Occurs before Saving a RelationType
Declaration
public static event TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> SavingRelationType
Event Type
Type | Description |
---|---|
TypedEventHandler<IRelationService, SaveEventArgs<IRelationType>> |