我正在尝试像
这样的事情GetQueryable<Requirement>()
.OrderByDescending( y => y.BidsReceieved.Count() )
.ToList();
但失败了,例外
Infrastructure.DataAccess.RequirementRepositoryTests.IsOrderbyBidCountWorking' failed: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException : Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.OrderByDescending[KHM.Domain.Entities.Requirement,System.Int32](NHibernate.Linq.NhQueryable`1[KHM.Domain.Entities.Requirement], Quote((y, ) => (.Count[KHM.Domain.Entities.Bid](y.BidsRecieved, ))), )]
at NHibernate.Hql.Ast.ANTLR.ErrorCounter.ThrowQueryException()
at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate()
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole)
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
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.NhQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)
at NHibernate.Linq.NhQueryProvider.Execute[TResult](Expression expression)
at Remotion.Data.Linq.QueryableBase`1.GetEnumerator() in :line 0
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
DataAccess\Repositories\RequirementsRepository.cs(49,0): at KHM.Infrastructure.DataAccess.Repositories.RequirementsRepository.Orderbybids()
Infrastructure\DataAccess\RequirementRepositoryTests.cs(115,0): at KHM.IntegrationTests.Infrastructure.DataAccess.RequirementRepositoryTests.IsOrderbyBidCountWorking()
我想根据收到的出价来订购要求。 我正在使用linq-to-nhibernate,我正在使用nhibernate3.1