LINQ to NHibernate - .GroupBy().Skip().Take() 导致异常 [英] LINQ to NHibernate - .GroupBy().Skip().Take() cause an exception

查看:81
本文介绍了LINQ to NHibernate - .GroupBy().Skip().Take() 导致异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NHibernate 3.3.1.4000 版

NHibernate version 3.3.1.4000

查询:

IQueryable<Activity> activities = _repository.GetList<Activity>();

IQueryable<ActivityStatistic> statistics = activities
    .GroupBy(activity => activity.ActivityLicense.SerialNumber)
    .Select(grouping => new ActivityStatistic
        {
            ActivityCount = grouping.Count(),
            LicenseCode = grouping.Key              
        })
    .OrderBy(stat => stat.LicenseCode);

List<ActivityStatistic> result = statistics
    .Skip(request.StartIndex)
    .Take(request.Count)
    .ToList();

如果我评论 Skip/Take 代码,它就可以正常工作.在 OrderBy 使用 LINQ to NHibernate 之后,如何在不调用 ToList() 的情况下使其协同工作?

If I comment Skip/Take code, it works properly. How can I make it to work together without calling ToList() after OrderBy using LINQ to NHibernate?

提前致谢.

更新:

异常:

The method or operation is not implemented.

 at NHibernate.Linq.GroupBy.AggregatingGroupByRewriter.FlattenSubQuery(SubQueryExpression subQueryExpression, QueryModel queryModel)
   at NHibernate.Linq.GroupBy.AggregatingGroupByRewriter.ReWrite(QueryModel queryModel)
   at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root)
   at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory)
   at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
   at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
   at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
   at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)
   at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)
   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
   at Remotion.Linq.QueryableBase`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MBP.AuthorizationService.Logic.LicenseService.GetActivityStatistic(CommonRequest request, Int32& recordsCount) in D:\Projects\MBP.Launcher\MBP.AuthorizationService.Logic\LicenseService.cs:line 201

推荐答案

Michael Petito 对问题的回答:

Michael Petito answered to the question:

这是我刚刚遇到的一个已知问题:nhibernate.jira.com/browse/NH-2566 – Michael Petito 8 月 22 日 19:56

This is a known issue that I just ran into as well: nhibernate.jira.com/browse/NH-2566 – Michael Petito Aug 22 at 19:56

等待新版本...

这篇关于LINQ to NHibernate - .GroupBy().Skip().Take() 导致异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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