这是SQL ORDER BY:

order by case when [order] is null then 1 else 0 end, [order]


如何在LINQ-To-Object语句中编写它?

最佳答案

方法语法

var query = enumerable.OrderBy(x => x.order == null ? 1 : 0).ThenBy(x => x.order);


查询语法

var query = from x in enumerable
            orderby (x.order == null ? 1 : 0), x.order
            select x;

关于c# - 如何将该SQL Order By语句转换为LINQ-To-Object?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12479029/

10-17 02:03