views:

25

answers:

1

Lets say I have a many-to-many relationship:

  • Group table
  • User table
  • group_user table which is a many to many table

Given the group name I would like to find all the users that belong to this group. How can I do this with subsonic 3.0?

IQueryable<group_user> groupUser= group_user.All();

Is it possible from groupUser to get all users who belong to a specific group say group 1? Is there any other way

A: 

Use a linq statment.

something like (very rough):

var users = from gu in group_user.All()
join g on group.All()
join u on user.All()
where g.Name = "My Group"
select u;

If you provide me with your schema I'll be able to knockup a working example.

DaveHogan