// 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://stackoverflow.com/questions/13394712/keep-null-values-last-in-nhibernate-sorting