Joins using collections

Thread is closed for posting
2 posts, 0 answers
  1. Craig
    Craig avatar
    3 posts
    Member since:
    Jun 2009

    Posted 01 Jul 2009 Link to this post

    How do we join one object on a collection of objects that are stored in another object (using Linq).


    users object

    roles object

    roles object has a collection of user objects.

    we want to get a list of users that are mapped to a single role.

    as standard sql it would be

    select users.* from users
        inner join users_in_roles on
        inner join roles on users_in_roles on

  2. Alexander
    Alexander avatar
    727 posts

    Posted 02 Jul 2009 Link to this post

    Hello Craig,

    I guess you are using the Reverse mapping approach. Please, take a look at this knowledge base article to get familiar with the process. Note the last step described - you have to enable the inverse collection option in order to get a list of Users in the Role class. After doing this, you will not even have to execute a query at all - each Role will have the collection with the related Users and you can reach it by using the Role.Users property.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top