Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您好,我的数据库中有一个菜单结构,格式如下:
Id | Id_Parent | Menu
我需要让这个数据结构按顺序id排列id_parent。
id
id_parent
我如何使用 linq 进行此查询?
var orderedData = data.OrderBy(i => i.Id).ThenBy(i => i.Id_Parent);
@des 的答案是正确的,但这里是带有查询语法的相同查询(我发现它更具可读性)
var orderedData = from x in data orderby x.Id, x.Id_Parent select x;