U4-2237 - [6.1] RelationService API

Created by Vincent Baaij 15 May 2013, 08:25:49 Updated by Morten Christensen 22 May 2013, 09:53:24

In the 6.1 Beta the RelationService API is implemented. One of the available methods is GetAllRelations(params int[] ids)

Is it supposed to give you all relation for the supplied relation id's? If so, than its working as advertised :).

If it is supposed to give you all relations where the supplied id's are either the ParentId or ChildId (content item), then it's not working. I think it will be useful to have such a method as a supplement to the GetByChildId(id) and GetByParentId(id) methods

For a single content item it could be something like public IEnumerable GetByContentId(int id) { using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork())) { var query = new Query().Where(x => x.ParentId == id || x.ChildId == id); return repository.GetByQuery(query); } } Sorry, don't know how to code it for multiple Id's

Comments

Morten Christensen 15 May 2013, 10:09:25

Yeah, I can understand the confusion with the GetAllRelations method. Its actually for getting all relations and optional supply the ids of the relation itself. So not Child or Parent Id but the id of the relation.

  • ''If it is supposed to give you all relations where the supplied id's are either the ParentId or ChildId (content item)'' No
  • ''Is it supposed to give you all relation for the supplied relation id's?'' Yes. Is it not returning anything at all? It works in exactly the same way as the other service/repository methods that return all, so will need a bit more info to investigate.


Morten Christensen 15 May 2013, 10:13:03

If you want to get relations for a single content item you should use either: GetByParentId(id) - where id is the integer id of the content item. This returns relations where the content is the parent relation. OR GetByChildId(id) - where id is the integer id of the content item. This returns relations where the content is the child relation.


Vincent Baaij 15 May 2013, 10:16:29

It's returning the relations for the supplied relation ids, so no problem there.

Have solved my problem by using GetByParent(id)

Don't you think the suggested function offers some value?


Morten Christensen 15 May 2013, 13:05:54

Just to make sure I understand it correct you want something like GetParentByIds(params int[] ids) and GetChildByIds(params int[] ids) ? Currently that would just be translated to a foreach to GetParentById/GetChildById because we don't have an optimized way of getting multiple entities by a property value. So we can easily add it, but it would not be optimized.


Vincent Baaij 15 May 2013, 13:37:20

Nope, that's not what I meant. What I 'want' is a method you call with a content Id that gives you all the relations where the id occurs as a parent or a child

like the IsRelated method but instead of returning a bool it returns all relations for the supplied id


Morten Christensen 16 May 2013, 08:48:48

Okay, yes. Should be pretty simple to add.


Priority: Normal

Type: Feature (request)

State: Fixed

Assignee: Morten Christensen

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted: Inline code

Affected versions: 6.1.0

Due in version: 6.1.0

Sprint:

Story Points:

Cycle: