LINQ中的多个“order by”

a 夏天 提交于 2020-08-10 17:56:16

问题:

I have two tables, movies and categories , and I get an ordered list by categoryID first and then by Name . 我有两个表, moviescategories ,我首先按类别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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!