我试图创建执行以下linq查询:
result = (from user in context.vwUsers
join boardMember in boardMembers
on user.nationalNo equals boardMember.nationalNo
select user).ToList();
但我得到以下例外:
System.NotSupportedException:无法创建常量值 输入' DataAccessLayer.User'。只有原始类型或枚举类型 在这种情况下得到支持。
更多信息:
boardMembers
是以下linq查询的结果:
var boardMembers = (from complex in context.ApartmentGroups
where complex.grpId == complexId
select complex).First().Users;
我试图从db获取vwUsers
列表,我的代码正在尝试执行以下操作:
1.从db获取用户列表(类型为User
)
2.将先前的列表转换为vwUser
的列表。
答案 0 :(得分:0)
试试这个,
var boardMembers = (from complex in context.ApartmentGroups
where complex.grpId == complexId
select complex).FirstOrDefault().Users;
- 要求结果,请执行此操作
var result = from c in context.vwUsers
where boardMembers.Select(x=>x.nationalNo).Contains(c.nationalNo)
select c;