将个案转换为Linq语句

时间:2019-10-13 09:59:38

标签: linq

我有一个查询,例如;

select * from TABLE_DEF_ROLE order by case when RoleName = 'Select All' then 0 else 1 end, RoleName

我已经检查了相关的问题和答案,但仍然无法解决。我如何将其转换为linq语句?

1 个答案:

答案 0 :(得分:0)

您可以尝试以下方法:

var roles = from r in db.Roles
        orderby r.RoleName == "Select All" ? 0 : 1 descending
        select r;

({Roles实体引用您的表)

相关问题