2010-05-31 5 views
0

Existe-t-il un moyen d'utiliser SQL personnalisé avec NHibernate? Je veux utiliser un SQL complexe pour une colonne spécifique.NHibernate - utilisation d'une requête SQL personnalisée pour une colonne

Exemple:

select id, viewsCount, commentsCount, 
    0.2 * viewsCount/(select top 1 viewsCount from articles where isActive = 1 order by viewsCount DESC) as priorityViews, 
    0.8 * commentsCount/(select top 1 commentsCount from articles where isActive = 1 order by commentsCount DESC) as priorityComments, 
    round(0.2 * viewsCount/(select top 1 viewsCount from articles where isActive = 1 order by viewsCount DESC) + 
    0.8 * commentsCount/(select top 1 commentsCount from articles where isActive = 1 order by commentsCount DESC), 1) as priority 
from articles 

Répondre

Questions connexes