@
gDD @
icyflash @
magicshui @
leqoqo @
haohaolee public class User
{
[Key]
public int UserID { get; set; }
[Required]
[DisplayName("登陆名")]
public string NickName { get; set; }
[Required]
[DisplayName("用户姓名")]
public string UserName { get; set; }
[Required]
[DisplayName("联系电话")]
public string Phone { get; set; }
[Required]
[DisplayName("用户组")]
public int GroupID { get; set; }
public virtual IList<UserRight> UserRights { get; set; }
}
public class UserRight
{
[Key]
public int UserRightID { get; set; }
public int UserID { get; set; }
public int RightID { get; set; }
public bool? AsParent { get; set; }
public bool? AsDefault { get; set; }
public virtual User User { get; set; }
public virtual Right Right { get; set; }
}
下面是linq语句,查询某个User之后,获取其所有的Rights
var rights = user.UserRights.Select(ur=>ur.Right).ToList();
这个用sql profile看就变成n条查询了。