This question is locked. New answers and comments are not allowed.
Hi,
Thank you for your help in advance!
I have the following query:
This query works fine. When I databind this to say, a grid, everything is as it should be:
Now, when I put in a distinct clause into the mix, like so:
I lose the orderby from the original query. A comment on this article explains that if a distinct clause is used after an orderby clause, then the orderby is ignored.
Can someone please tell me how I can implement both the orderby and distinct in this situation?
Cheers,
-alex
Thank you for your help in advance!
I have the following query:
var sortedResult = from element in scope.Extent<ORM.Movieinstancecinema>() where NowShowingList.Contains(element.Movieinstance) && element.CinemaId == cinemaId orderby element.AdjustedReleaseDate descending select element.Movieinstance;This query works fine. When I databind this to say, a grid, everything is as it should be:
GridView1.DataSource = sortedResult.Take(6);Now, when I put in a distinct clause into the mix, like so:
GridView1.DataSource = sortedResult.Distinct().Take(6);I lose the orderby from the original query. A comment on this article explains that if a distinct clause is used after an orderby clause, then the orderby is ignored.
Can someone please tell me how I can implement both the orderby and distinct in this situation?
Cheers,
-alex