LINQ查询表达式中,orderby子句可以对查询结果进行排序。排序方式可以为“升序”或“降序”,且排序的键可以为一个或多个。

注意:LINQ查询表达式对查询结果的默认排序方式为“升序”。

实例:

1                    var values = from u in users
2 
3                                                 where u.ID < 6
4 
5                                                 orderby u.Username descending
6 
7                                                 select u;

(2)实例二多个字段排序

1                    var values = from u in users
2 
3                                                 where u.ID < 6
4
5                                                 orderby u.Username descending,u.ID ascending
6 
7                                                 select u;

 

相关文章:

  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-24
  • 2022-12-23
  • 2022-03-02
  • 2021-07-16
  • 2021-11-08
  • 2022-01-06
  • 2021-10-14
相关资源
相似解决方案