упорядочить по количеству дочерних элементов с помощью linq to nhibernate не удается - PullRequest
1 голос
/ 14 ноября 2011

Я пробую что-то вроде

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

1 Ответ

0 голосов
/ 07 ноября 2012

является ли BidsReceeded коллекцией?

, если это так, я думаю, что вы должны использовать BidsRececeive.Count, но не BidsRececeive.Count ().Здесь нет скобки.

...