query = query.OrderBy(p => p.IsTop).ThenOrderByDescending(p => p.JobId)?
我想按 IsTop
属性升序对对象进行排序,然后按 JobId
属性降序对对象进行排序:
query = query.OrderBy(p => p.IsTop).ThenOrderByDescending(p => p.JobId);
我该如何操作?我知道相反的情况:
query = query.OrderByDescending(p => p.IsTop).ThenBy(p=>p.JobId)
语法有效,但不是我想要的。我想要的实际上是无论什么情况 IsTop
项目都将位于顶部!
I want to sort objects by IsTop
property ascending and then by JobId
property descending:
query = query.OrderBy(p => p.IsTop).ThenOrderByDescending(p => p.JobId);
How do I do this? I know the reverse:
query = query.OrderByDescending(p => p.IsTop).ThenBy(p=>p.JobId)
Syntax works but it's not what I want. What I want is actually whatever situation is the IsTop
items will be at the top!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Bool 按升序排序为 false,为 true。
尝试:
query.OrderByDescending(p => p.IsTop).ThenByDescending(p => p.JobId);
Bool sorted in ascending order is false, true.
Try:
query.OrderByDescending(p => p.IsTop).ThenByDescending(p => p.JobId);