NHibernate - using custom sql query for a column
Posted
by stacker
on Stack Overflow
See other posts from Stack Overflow
or by stacker
Published on 2010-05-31T21:42:14Z
Indexed on
2010/05/31
21:53 UTC
Read the original article
Hit count: 232
nhibernate
|query
Is there anyway to use custom sql with NHibernate? I want to use custom sql for a specific column.
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
© Stack Overflow or respective owner