Copied to clipboard

Flag this post as spam?

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


  • Matthieu Nelmes 102 posts 385 karma points
    Oct 29, 2015 @ 15:56
    Matthieu Nelmes
    0

    Relations GetByParent?

    I have a scenario where members will be linked to (multiple) Doctype venues.

    I'm just trying to decide the best way to query the relationship between the two and am looking at the relation API.

    I've setup a Parent > Child relationship between the Member and Doctype, now I would like to load all associated Doctypes for a user when they login.

    I've got as far as this but now I'm stuck, should I use GetByParent/GetByRelationTypeAlias?

    var memberService = Services.MemberService;
    var relationService = Services.RelationService;
    
    var member = memberService.GetById(Members.GetCurrentMemberid())
    
    relationService.GetByParent???
    

    Either option looks like it returns an IEnumerable

    *EDIT* Or should I be looking at different ways to relate members with content? I've now seen that there's no inbuilt way to manage relationships without a 3rd party package. I originally had a member picker property on the documents that allowed admin users to simply assign members, I could also populate this easily via ContentService on creating a new document, however I thought it may get sluggish having to loop through every document checking for that property when the user logged in and the relation functionality looked as though it would be more efficient.

    Any input or suggestions would be helpful. thanks!

  • Matthieu Nelmes 102 posts 385 karma points
    Oct 29, 2015 @ 16:17
    Matthieu Nelmes
    100

    I did what I always do and I went charging in before trying something out.

    Found you can GetByRelationTypeAlias() which returns a list of objects with associated Parent/Child Node Id's

    object relatedItems = relationService.GetByRelationTypeAlias("venueAdmins").Where(x => x.ParentId == member.Id).ToList();
    
Please Sign in or register to post replies

Write your reply to:

Draft