简体   繁体   English

Odata覆盖orderby的行为

[英]Odata override behaviour of orderby

My date column in sql table can be null, so I getting that data using OData but if I order it by asc, null values is in front of all other rows. 我在sql表中的date列可以为null,因此我使用OData获取该数据,但是如果按asc排序,则null值将位于所有其他行的前面。 I want that it be desplayed after all others: 我希望它在所有其他对象之后被取消显示:

 1. 31.12.2000
 2. 31.12.2010
 3. null

Is there is possibility to somehow override filtering so it take null value as may be DateTime.MaxValue? 是否有可能以某种方式覆盖过滤,使其采用空值(如DateTime.MaxValue)?

The ANSI standard supports NULLS FIRST and NULLS LAST , but SQL Server does not have these options. ANSI标准支持NULLS FIRSTNULLS LAST ,但是SQL Server没有这些选项。

Instead, you can use two keys in the ORDER BY : 相反,您可以在ORDER BY使用两个键:

order by (case when col is not null then 1 else 2 end),
         col asc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM