2
votes
@accounts.UserProfiles.ElementAt(item.AuthorID).ProfilePicture

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

2

2 Answers

1
votes

Neither ElementAt nor ElementAtOrDefault is supported in LINQ to Entities.

You can find list of all supported method on MSDN: Supported and Unsupported LINQ Methods (LINQ to Entities)

1
votes

ElementAt(x) and ElementAtOrDefault(x) are not supported: .NET 3.5, .NET 4.5

However, you could use

source.Skip(x).First() 

or respectively

source.Skip(x).FirstOrDefault() 

to achieve similar results.

Note that Skip() requires its source to be sorted (with an 'OrderBy' clause).