问:


 

I have two tables, movies and categories, and I get an ordered list by categoryID first and then by Name.
The movie table has three columns, ID, Name, and CategoryID. The category table two has columns, ID, and Name.


I tried something like the following, but it didn't work.

var movies = _db.Movies.OrderBy( m => { m.CategoryID, m.Name })

 

 

答:


 

This should work for you:

var movies = _db.Movies.OrderBy(c => c.Category).ThenBy(n => n.Name)

 

 

原文链接

 

相关文章:

  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-07-15
  • 2021-08-10
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2021-11-15
  • 2021-09-21
  • 2022-12-23
  • 2021-06-13
相关资源
相似解决方案