nhibernate - 流畅的 nhibernate 不支持异常 newexpression

标签 nhibernate linq-to-nhibernate

谁能帮我弄清楚我做错了什么。我是 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/

相关文章:

c# - ASP.NET Identity - 无法注册 UserTokenProvider

nhibernate - Fluent NHibernate - 需要对单个延迟加载的 SQLite 数据库进行多程序访问

c# - 使用 AutoInc 的 FluentMapping ComposedId

Linq 到 NHibernate 多个 OrderBy 调用

c# - 条件分组正在被删除

NHibernate 多对多删除导致外键冲突

NHibernate 错误报告建议

c# - FluentNHibernate RTM 和 NHibernate.Linq

NHibernate 3 LINQ : How to filter IQueryable to select only objects of class T and its subclasses?

nhibernate - 如何优化这个 Nhibernate 查询(835ms)