如何更改列表的顺序? [英] How to change the order of the list?

查看:122
本文介绍了如何更改列表的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文章:

在这里输入的形象描述

我想要显示所有包含的状态等于6在最后名单的纪录。 (*状态将是任何从1开始到20不同的属性。)

Where i want to show all the records which contains Status equals to 6 at the last of the list. (*The status would be any starting from 1 to 20 for different properties.)

我怎样才能做到这一点?

How can i do this?

推荐答案

如果我理解这个正确的话,你可以使用的OrderBy()通过以下方式,使项目与状态== 6 其他项目后,将返回:

If I understand this correctly, you can use OrderBy() in the following way so that items with Status == 6 are returned after the other items :

OrderBy(o => o.Status == 6 ? 1 : 0)

这篇关于如何更改列表的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆