我是entity frame work
中的新手,并编写此查询:
var query_Books = (from p in Store1.CustomerBooks
where p.CustomerID == query_User[i].id
select new
{
p.BookName,
p.BookCount
}).ToArray();
但是获取此错误:
Additional information: The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.
这是我的query_User
查询:
var query_User = (from p in Store1.CustomerBuys
where p.NationalCode.Trim() == NationalCode
select new
{
p.id,
p.NationalCode
}).ToArray();
我该如何解决这个问题?
linq无法将query_User[i]
转换为expression
。使用临时变量来工作,类似的东西:
var user = query_User[i];
var query_Books = (from p in Store1.CustomerBooks
where p.CustomerID == user.id
select new
{
p.BookName,
p.BookCount
}).ToArray();
将此query_User[i].id
保存到温度变量。然后在查询中使用该温度变量。