I have to show the movies which have most wanted to see status. For this I Join two tables 1. MovieInformation and 2. SeentItWantToSeeIt. I calculated most wanted to see movie with this code snippets.
public class RangkedMovieList
{
public int MovieID { get; set; }
public int count { get; set; }
}
rankedList = db.SeenItWantToSeeIt.Where(m => m.Status == 1 && m.MovieID != null)
.GroupBy(m => m.MovieID)
.Select(g => new RangkedMovieList
{ MovieID = g.Key.Value,
count = g.Count()
})
.ToList();
AllMovieInfo is Iqueryable with which I joined wanted to see movies.
AllMovieInfo = (from r in rankedList
join a in AllMovieInfo on r.MovieID equals a.MovieID
orderby r.count descending
select a).Distinct().AsQueryable();
This query works fine and orders the result by MovieID but I want to order all movies by their wanted to see count. Though I have written code to orderby r.count descending, Its not working. Please help me out.