谁能帮我弄清楚我做错了什么。我是 nhibernate 的新手,我发现很难真正适应它。我有这个查询:
var results2 = (from purchase in _session.Query<Purchase>()
group purchase by new { purchase.symbol } into purchases
select new Quote()
{
shares= purchases.Sum(p => p.shares)
}).ToList();
但我得到了 notsupportedexception 并且错误消息只是 newexpression。
最佳答案
查看问题的日期,我猜这个问题是关于 NHibernate pre-3.2 的。
假设您的 Quote
是一个简单的 POCO 类并且您使用 NHibernate 3.2 或更高版本,此查询工作正常 - 参见 my blog post有关 GroupBy
的一些详细信息NHibernate 中的功能。
所以解决办法就是升级。
关于nhibernate - 流畅的 nhibernate 不支持异常 newexpression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4652044/