Method 'SingleOrDefault' not supported by Linq to Entities
- by user300992
I read other posts on similar problem on using SingleOfDefault on Linq-To-Entity, some suggested using "First()" and some others suggested using "Extension" method to implement the Single().
This code throws exception:
Movie movie = (from a in movies
where a.MovieID == '12345'
select a).SingleOrDefault();
If I convert the object query to a List using .ToList(), "SingleOrDefault()" actually works perfectly without throwing any error.
My question is: Is it not good to convert to List? Is it going to be performance issue for more complicated queries? What does it get translated in SQL?
Movie movie = (from a in movies.ToList()
where a.MovieID == '12345'
select a).SingleOrDefault();