I faced a problem with entity framework. I'm trying sort my collection by average value from one of the key:
var userPhotos = Database.Set<Photo>().Where(p => string.IsNullOrEmpty(userId) || p.ClientProfileId == userId);
usersPhotos = usersPhotos.OrderByDescending(item => item.Votes.Average());`
In the last line of code I have "The specified type member 'Votes' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported." execpetion. My member Votes looks like so:
public class Photo : BaseEntity, IEntity<Guid>
{
public Photo()
{
Id = Guid.NewGuid();
Votes = new List<double>;
}
[Key]
public Guid Id { get; set; }
//Other fields
public ICollection<double> Votes { get; set; }
}
How to fix my problem and make sort by avarege value of this member?