diff --git a/src/Umbraco.Core/Services/RelationService.cs b/src/Umbraco.Core/Services/RelationService.cs index 3d3d0d9e3e..83d09023ab 100644 --- a/src/Umbraco.Core/Services/RelationService.cs +++ b/src/Umbraco.Core/Services/RelationService.cs @@ -140,6 +140,21 @@ namespace Umbraco.Core.Services return repository.GetByQuery(query); } } + + /// + /// Gets a list of objects by their child or parent Id. + /// Using this method will get you all relations regards of it being a child or parent relation. + /// + /// Id of the child or parent to retrieve relations for + /// An enumerable list of objects + public IEnumerable GetByParentOrChildId(int id) + { + using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork())) + { + var query = new Query().Where(x => x.ChildId == id || x.ParentId == id); + return repository.GetByQuery(query); + } + } /// /// Gets a list of objects by the Name of the