The following test is a variation of the test in NH-2560 Closed . That test works now, after recent commits. This variation puts the ordering expression inside the call to OrderBy(), before the projection. This fails due to flawed SQL.
public void SingleKeyPropertyGroupAndOrderByCountBeforeProjection()
// This is a variation of SingleKeyPropertyGroupAndOrderByProjectedCount()
// that puts the ordering expression inside the OrderBy, without first
// going through a select clause.
var orderCounts = db.Orders
.GroupBy(o => o.Customer.CustomerId)
.OrderByDescending(g => g.Count())
AssertOrderedBy.Descending(orderCounts, oc => oc.OrderCount);
The generated SQL. Notice missing count in the order by clause. There is also a superflouos join, but I suspect that may be covered by NH-3003 Closed .
customer1_.CustomerId as col_0_0_,
cast(count as INT) as col_1_0_
left outer join