How to solve this error in C#?

c#, c#-4.0, linq, linq-to-entities

Solution

I guess you're still working in `IQueriable`. Try instead

var vv = v1.ToList().LastOrDefault();

or, more elegant

var vv = v1.AsEnumerable().LastOrDefault();

Problem

I'm getting an error when using the following code ``` var v1 = from P in db1.QuranWordsNews where P.Aye == perId select P; var vv = v1.LastOrDefault(); // The error occurs here ``` The message: LINQ to Entities does not recognize the method 'TashihQuran.QuranWordsNew LastOrDefaultQuranWordsNew' method, and this method cannot be translated into a store expression.

Original source

Related problems