Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 15, 2014 @ 13:34
    Simon Dingley
    0

    How to get content relations in v6.1.x

    In v6.1.x are we still using the old Relation.GetRelations(nodeId) API call or is there a new way of doing this?

    Thanks, Simon

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 15, 2014 @ 15:06
    Simon Dingley
    0

    I see there is a new RelationsService but no documentation yet, is this the corect way of doing things?

    RelationType relationType = rs.GetRelationTypeByAlias("relateDocumentOnCopy");
    IEnumerable<Relation> relations = rs.GetAllRelationsByRelationType(relationType).Where(r => r.ParentId == node.Id);
    

    Thanks, Simon

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 15, 2014 @ 15:42
    Simon Dingley
    100

    I've made a start on documenting the service and will submit a pull request when done however in doing so I've discovered a more suitable method of achieving of what I am after and re-factored it as follows:

    RelationService rs = ApplicationContext.Current.Services.RelationService;
    IEnumerable<Relation> relations = rs.GetByParentId(node.Id).Where(r => r.RelationType.Alias == "relateDocumentOnCopy");
    
  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jan 15, 2014 @ 16:52
    Simon Dingley
    0

    I've had a go at documenting the service now and sent a pull request so hopefully it is accepted and can be of use to others:

    https://github.com/umbraco/Umbraco4Docs/pull/120

  • Jonathan Crosby 12 posts 33 karma points
    Feb 23, 2014 @ 23:07
    Jonathan Crosby
    0

    Hi there

    I have seen your documentation, thanks for this. I am having quite some trouble getting my relations working in the new code. Any help would be much appreciated: http://our.umbraco.org/forum/developers/razor/48594-Language-Dropdown-Help-Required-Umbraco-703

     

    Kind regards
    Jonathan

Please Sign in or register to post replies

Write your reply to:

Draft