NHibernate - 使用自定义sql查询列
问题描述:
有没有什么办法可以使用NHibernate自定义sql?我想为特定的列使用复杂的SQL。NHibernate - 使用自定义sql查询列
例子:
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