LINQ到实体无法识别方法ElementAt(I) [英] LINQ to Entities does not recognize the method ElementAt(i);

查看:1134
本文介绍了LINQ到实体无法识别方法ElementAt(I)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的方法ElementAt为得到一个查询结果的特定元素。

i'm using the method elementat for get a specific element of a query's result.

var mds = db.TDP_MissioniDestinazioni.Where(
                                  p => p.MissioneID == missioneRow.MissioneID);  

destinazioneRow = mds.ElementAt(i);

LINQ to Entities does not recognize the method 
'TimeEntModel.TDP_MissioniDestinazioni 
ElementAt[TDP_MissioniDestinazioni]     
(System.Linq.IQueryable`1[TimeEntModel.TDP_MissioniDestinazioni], Int32)' 
method, and this method cannot be translated into a store expression.



为什么?

Why?

如何修复它?
感谢

how can i fix it? thanks

推荐答案

您快乐获取所有的早的结果吗?如果是这样,无论是通话了ToList()对其进行缓存,或 AsEnumerable()来在每次调用获取他们,在 AsEnumerable 只是作为一个方法来强制编译器调用 Enumerable.ElementAt 而不是可查询。.ElementAt

Are you happy to fetch all the "earlier" results? If so, either call ToList() to cache them, or AsEnumerable() to fetch them on each call, with the AsEnumerable just being a way to force the compiler to call Enumerable.ElementAt instead of Queryable.ElementAt.

有可能是一个更好的方法(例如,使用带或跳过),但 - 你可以给有关的大局观更多信息?

There may be a better way (e.g. using Take or Skip) though - could you give more information about the bigger picture?

这篇关于LINQ到实体无法识别方法ElementAt(I)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆