using (var dataContext = new realtydbEntities())
{
var user =
(
from aspnet_Roles rol in dataContext.aspnet_Roles.Include("aspnet_Users")
from aspnet_Users usr in rol.aspnet_Users
where rol.RoleId == roleID
select usr
);
return user.ToList();
}
我想用
usr.MemberShip.Email
MemberShip是外表的外表。
但是我收到了一个错误: ObjectContext实例已被处理,不能再用于需要连接的操作。
如何将成员资格对象包含在结果??????
中答案 0 :(得分:0)
您很可能需要包含挂起aspnet_User表的aspnet_Membership表,如下所示:
using (var dataContext = new realtydbEntities())
{
var user =
(
from aspnet_Roles rol in dataContext.aspnet_Roles.Include("aspnet_Users")
from aspnet_Users usr in rol.aspnet_Users.Include("aspnet_Membership")
where rol.RoleId == roleID
select usr
);
return user.ToList();
}