Devo ordinare il risultato nella tabella DB ChargeOperations
in la mia direzione entro il typeId
. La richiesta SQL è come questo:Come utilizzare il caso e ordinare in Nhibere?
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
Quindi, per favore, mi puoi dare un esempio di come posso creare questa costruzione.
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
con QueryOver.
è 'TypeId' il valore discriminatore? hai bisogno di Paging? – Firo
Non conosco il tuo significato come valore discriminatore. TypeId è un campo per l'ordinamento. Non ho bisogno di Paging o di altro. So come crearlo con HQL, ma usiamo queryOver ... –