问题
Can I use a Linq To Entities subquery within a (linq to entities) Select clause to fetch a filed value like this:
var a = someIQueryable;
var b = IQueryable_2.Select((a,i)=> new Model
{
SomeFiled = someIQueryable.Where(w=>w.AA==a.AA).Select(w=>w.Calls).First()
}).ToList();
I am getting "Cannot translate method into store expression".
Is there any way to do this ?
回答1:
I think the issue is caused by Select
method (though you could probably provide more details). I'm not sure why you use Select
overload with index parameter if you do not use it. Use another Select
overload:
var b = IQueryable_2.Select(a => new Model
{
SomeFiled = someIQueryable.Where(w=>w.AA==a.AA)
.Select(w=>w.Calls).First()
}).ToList();
来源:https://stackoverflow.com/questions/5485848/use-linq-to-entities-subquery-within-select-clause-to-fetch-a-field-value