EF - order by specific values

Posted h.yl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EF - order by specific values相关的知识,希望对你有一定的参考价值。

 

List<string> s = new List<string>() { "A", "B", "A", "C", "B", "C", "D", "E" };

            s = s.OrderByDescending(w => w == "C").ToList(); //.ThenBy(q => q).ToList();

//result: C,C, A,B,A,B,D,E

            s = s.OrderByDescending(w => w == "C").ThenBy(q => q).ToList();


//result: C,C, A,A,B,B,D,E

 

以上是关于EF - order by specific values的主要内容,如果未能解决你的问题,请参考以下文章

EF Core group by 和 order by

为啥 EF Core 最后要添加一个额外的 ORDER BY

EF Core 3 - 不必要的 ORDER BY 减慢查询

Spring Cloud Gateway-过滤器按照order排序

SQL语句中,为啥where子句不能使用列别名,而order by却可以?

使用 ORDER BY 查询 CosmosDB 子集合