I have two classes:
public class User
{
public User()
{
this.Groups = new List<Group>();
}
public long Id { get; set; }
public string Name { get; set; }
public IList<Group> Groups { get; set; }
}
and
public class Group
{
public Group()
{
this.Users = new List<User>();
}
public long Id { get; set; }
public string Name { get; set; }
public IList<User> Users { get; set; }
}
I have defined a many-to-many relationship with OpenAccess by using a join table:
mapping.HasAssociation(user => user.Groups).WithOpposite(group => group.Users).MapJoinTable("UserGroup", (user, group) => new
{
UserId = user.Id,
GroupId = group.Id
});
I would like to get all users who are associated to the group x.
How to write the linq request ?
I finally want to remove the group x after removing of all links (user/group) to this group. Or is it possible to make it automatically by a cascade delete ? I am interesting by the two solutions.