我的代码中有类似的查询尝试执行组连接:
var query = from client in _clientsRepository.Query()
join order in _ordersRepository.Query()
on client.Id equals order.Client.Id into orders
select new Model(client, orders);
它与101 Linq样本几乎完全相同,但是,每当我运行它时,我得到它 以下例外:
{"无法转换类型的对象 ' Remotion.Linq.Clauses.GroupJoinClause'输入 ' Remotion.Linq.Clauses.FromClauseBase'"}
不确定为什么会这样,我无法在网上找到任何答案。
这是堆栈跟踪:
at NHibernate.Linq.GroupJoin.GroupJoinAggregateDetectionVisitor.VisitQuerySourceReferenceExpression(QuerySourceReferenceExpression expression)
at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
at Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitAndConvert[T](T expression, String methodName)
at Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList[T](ReadOnlyCollection`1 list, Func`2 visitMethod)
at Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitNewExpression(NewExpression expression)
at NHibernate.Linq.Visitors.NhExpressionTreeVisitor.VisitExpression(Expression expression)
at NHibernate.Linq.GroupJoin.GroupJoinAggregateDetectionVisitor.Visit(IEnumerable`1 groupJoinClause, Expression selectExpression)
at NHibernate.Linq.GroupJoin.AggregatingGroupJoinRewriter.ReWrite(QueryModel model)
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.HQLExpressionQueryPlan.CreateTranslators(String expressionStr, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, 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.Execute(Expression expression)
at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)
at Remotion.Linq.QueryableBase`1.GetEnumerator()
at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()
有什么想法吗?