In LINQ to SQL, I get the exception \"The query operator \'ElementAt\' is not supported.\" When trying to use the ElementAt extension method on an IQueryable return
It is odd, in particular because Skip()
is supported. Could you, for example, do:
var obj = source.Skip(index).First();
?
From MSDN, Standard Query Operator Translation (LINQ to SQL) - this article contains the full list of operators that haven't been translated:
Operators with No Translation
The following methods are not translated by LINQ to SQL. The most common reason is the difference between unordered multisets and sequences.
Operators
Rationale
...
ElementAt , ElementAtOrDefault
SQL queries operate on multisets, not on indexable sequences.