问题:
I have two tables, movies and categories , and I get an ordered list by categoryID first and then by Name . 我有两个表, movies和categories ,我首先按类别ID获取有序列表,然后按名称获取 。
The movie table has three columns ID, Name and CategoryID . 影片表有三列ID,Name和CategoryID 。 The category table has two columns ID and Name . 类别表有两列ID和名称 。
I tried something like the following, but it didn't work. 我尝试了类似下面的内容,但它没有用。
var movies = _db.Movies.OrderBy( m => { m.CategoryID, m.Name })
解决方案:
参考一: https://stackoom.com/question/1Fi9/LINQ中的多个-order-by参考二: https://oldbug.net/q/1Fi9/Multiple-order-by-in-LINQ
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4478785