欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Nhibernate中Orderby的字段为空值时

程序员文章站 2024-03-16 09:18:58
...

// sql function definition
var sqlFunction = new SQLFunctionTemplate(NHibernateUtil.String
                                                         , "COALESCE(this_.AAA104, 0)");
// create projection
 var projection = Projections.SqlFunction(sqlFunction, 
   NHibernateUtil.Int32);

// order by projection
cr.AddOrder(new Order(projection, false));

参考链接:

https://*.com/questions/13394712/keep-null-values-last-in-nhibernate-sorting

相关标签: 后端开发