Как использовать case и order by в Nhibernate?

Мне нужно упорядочить результат в таблице БД ChargeOperations в моем собственном направлении по typeId . SQL-запрос выглядит так:

SELECT * FROM ChargeOperations co
LEFT JOIN ShadowChargeOperations sco ON sco.ChargeOperationId=co.Id
-- just exclude some extra data.
WHERE sco.Id IS NULL
ORDER BY
 CASE co.TypeId
  WHEN 1 THEN 3   -- this is my order, which is different from id of type and can change
  WHEN 2 THEN 1
  WHEN 3 THEN 2
  ELSE 4
 END,
 co.TypeId,
 co.CalculationAmount

Итак, пожалуйста, не могли бы вы привести мне пример того, как я могу создать эту конструкцию.

CASE co.TypeId 
  WHEN 1 THEN 3   -- this is my order, which is different from id of type and can change
  WHEN 2 THEN 1
  WHEN 3 THEN 2
  ELSE 4

с QueryOver.

5
задан Michał Powaga 17 December 2011 в 09:50
поделиться