我想从NHibernate的得到这个SQL:NHibernate中是否有算术运算投影?
SELECT SUM(color_pages) * SUM(total_pages)
FROM connector_log_entry
GROUP BY department_name
但我找不到任何地方的任何算术运算(*)的预测。
这是代码,我到目前为止有:
Session.QueryOver<ConnectorLogEntry>()
.SelectList(list => list
.SelectGroup(m => m.DepartmentName)
.WithAlias(() => dto.Department)
.Select(Projections.Sum<ConnectorLogEntry>(m => m.TotalPages))
//.Select(Projections.Sum<ConnectorLogEntry>(m => m.ColorPages))
.WithAlias(() => dto.TotalColorPercentage))
.TransformUsing(Transformers.AliasToBean<DepartmentConsumption>());
即使你可以用ICriteria来完成它,hql查询也会更具可读性。 – Sly 2011-01-28 14:04:34