【发布时间】:2009-12-15 12:45:21
【问题描述】:
我在之前的帖子here on stackoverflow 中看到了一个关于多对多关系的示例。为简单起见,让我们看看这些类:
public class Role(){
public int Id { get; set; }
public string Rolename { get; set; }
public string Description { get; set; }
}
public class User(){
public int Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public IList<UsersAndRoles> UsersAndRoles { get; set; }
}
public class UsersAndRoles(){
public int Id { get; set; }
public User User { get; set; }
public Role Role { get; set; }
}
这是写意的,所以请耐心等待。
现在对这些类进行 linq 查询的最佳方法是什么。可以说我想获得所有角色以及附加到他们的用户。有人可以帮我解决这个问题吗?
【问题讨论】:
标签: linq subsonic3 many-to-many