开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜