linq to entity asp.net mvc 多字段排序

时间:2021-10-08 21:19:46

字段1 降序

字段2 降序

var str = db.xxx.OrderByDescending(p=>p.字段1).ThenByDescending(p=>p.字段2)

ThenBy - 在 OrderBy 或 OrderByDescending 的基础上再正序排序
ThenByDescending - 在 OrderBy 或 OrderByDescending 的基础上再倒序排序