Reputation: 1387
AllMovieInfo = from movieInfo in AllMovieInfo
from countryMovie in movieInfo.SeenItWantToSeenIt
where countryMovie.Status==1
select movieInfo;
var seenitorderby = db.SeenItWantToSeeIt.Where(m => m.Status == 1).GroupBy(m => m.MovieID).Select(g => new {MovieID =g.Key,count=g.Count()}).OrderBy(o=>o.count);
List<int> seenItList=seenitorderby.Select(s=>s.MovieID).ToList();
AllMovieInfo = (from a in AllMovieInfo
from s in seenItList
where seenItList.Contains(a.MovieID)
select a).Distinct();
seenitorderby gives all the id of movie which have been seen most. so I want to join with AllMovieInfo,which is filterd movieinformation from other parameter. This query is ordering the result according to "AllMovieInfo.MovieID" which is obvious but I have to order the "result" according to the id that comes is "seenitorderby" eg: seen it orderby may take movieID 2,25,7,14,25 then I need AllMovieInfo according same order as seenitorderby .How can I order the "result" according to "seenitorderby " ?
Upvotes: 0
Views: 29
Reputation: 6793
Can you not use seenitlist as the primary list and join to the movieinfo? I believe (although I haven't tried) that they'll come out in the order of the primary list.
from s in seenItList
join a in AllMovieInfo on s equals a.MovieId
select a
You could probably simplify all of the linq queries in to one if you really want to which might make it more obvious to the next person who comes to read the code.
Upvotes: 1