Multiple "order by" in LINQ
Solution 1:
This should work for you:
var movies = _db.Movies.OrderBy(c => c.Category).ThenBy(n => n.Name)
Solution 2:
Using non-lambda, query-syntax LINQ, you can do this:
var movies = from row in _db.Movies
orderby row.Category, row.Name
select row;
[EDIT to address comment] To control the sort order, use the keywords ascending
(which is the default and therefore not particularly useful) or descending
, like so:
var movies = from row in _db.Movies
orderby row.Category descending, row.Name
select row;