From 0ff979e81436bd43f8173d4d8c2fa8e92ec80bb2 Mon Sep 17 00:00:00 2001 From: Morten Christensen Date: Wed, 22 May 2013 07:53:16 -0200 Subject: [PATCH] Adding missing method for retreiving parent or child relations. Implements #U4-2237 --- src/Umbraco.Core/Services/RelationService.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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