gpt4 book ai didi

c# - 如何将此 SQL Order By 语句转换为 LINQ-To-Object?

转载 作者:行者123 更新时间:2023-11-30 22:25:04 24 4
gpt4 key购买 nike

这是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com