Use Linq To Entities subquery within Select clause to fetch a field value
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 = IQueryab开发者_如何学JAVAle_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 ?
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();
精彩评论