从NHibernate获得汇总结果的最佳方法是什么? [英] What's the best way to get aggregate results from NHibernate?

查看:84
本文介绍了从NHibernate获得汇总结果的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我尝试在不同的实例中获取最小日期,最大日期和总和.我试图避免对SQL字符串进行硬编码或通过IList循环来获取这些值.

For example, I am trying to get a min date, a max date, and a sum in different instances. I am trying to avoid hard coding a SQL string or looping through an IList to get these values.

推荐答案

您可以通过NHibernate运行直接查询.或按信息添加其他顺序,以使生成的对象通过您感兴趣的参数按顺序排列.降序排列,第0个元素是您想要的最大值和最小值.等等.有两种以上的方法可以使冬眠的猫皮肤化.

You can run straight queries through NHibernate. Or add additional order by info so the resulting objects are in order via the parameter you're interested in. Order descending and your 0th element is what you want for max and mins. etc etc. There's more than one way to skin the hibernating cat.

这篇关于从NHibernate获得汇总结果的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆