LINQ NHibernate的 - 。.GroupBy()跳过()采取()会导致异常(LINQ t

2019-09-21 01:15发布

NHibernate的版本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();

如果我的评论跳过/送代码,它工作正常。 我怎样才能使它不必呼叫使用LINQ to NHibernate的排序依据后ToList()一起工作?

提前致谢。

更新:

例外:

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

Answer 1:

迈克尔Petito回答的问题:

这是一个已知的问题,我只是碰到了也:nhibernate.jira.com/browse/NH-2566迈克尔 - Petito 8月22日在19:56

等待新版本...



文章来源: LINQ to NHibernate - .GroupBy().Skip().Take() cause an exception