Prevent NHibernate from aliasing in ORDER BY

I have a query which has an Order By clause. The generated SQL from NHibernate looks like

 ORDER BY coalesce(x.Company as x__.Company, y.Company) asc 

This fails as 'as' is not allowed in Order by clause in MS SQL Server. Is there any way I can prevent aliasing?

The criteria query that I have written looks like:

 var orderBy = Projections.SqlFunction("coalesce", NHibernateUtil.String,      
                       Projections.ProjectionList() 
                      .Add(Projections.Property("x.Company"))
                      .Add(Projections.Property("y.Company")));

 var order = Order.Asc(orderBy);
 criteria.AddOrder(order);
1
задан WorldIsRound 3 September 2010 в 19:54
поделиться