The method ElementAt(i) is not recognized by LINQ to Entities.

c# entity entity-framework linq

Question

I use the techniqueelementat(Int32) to get a specified result component from a query.

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.

How do I repair this problem and why am I receiving it?

1
15
8/16/2017 8:42:46 PM

Accepted Answer

Do you like getting all of the "earlier" results? In such case, callToList() or to cache themAsEnumerable() to get them with each call using theAsEnumerable just being a means of compelling the compiler to callEnumerable.ElementAt in place ofQueryable.ElementAt .

Could you provide additional details about the wider picture? There could be a better approach (such utilizing Take or Skip).

22
2/26/2010 2:20:28 PM

Popular Answer

You may easily combineSkip and First the magic trick

mds.Skip(i).First()


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow