I’m dynamically building up a query starting with this:
var items = db.Items;
…
case "4":
items = items.OrderBy(x => x.Ratings.Average(t => t.score)).ThenBy(x => x.title);
The problem is that some items don’t have any data in the ratings table yet, so I believe it’s trying to average over data that doesn’t exist. Using DefaultOrEmpty() at the end doesn’t seem to have any effect. Any suggestions on how I would fix this?
Try that.