本文介绍了而使用LINQ to NHibernate的方法或操作未实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用LINQ NHibernate的3和我进行了如下的LINQ查询

i m trying to use linq to nhibernate 3 and i have made following linq query

 var a = (from c in Session.Query<ChoiceValue>()
                 join Specific in
                     (
                         (from choicevaluelocale in Session.Query<ChoiceValueLocale>()
                          where
                            choicevaluelocale.UICulture == "en-GB"
                          select new
                          {
                              choicevaluelocale.ChoiceValue.ChoiceGroup.ChoiceGroupName,
                              choicevaluelocale.ChoiceValue.ChoiceValueId,
                              choicevaluelocale.DisplayName,
                              choicevaluelocale.Description
                          }))
                       on new { c.ChoiceGroup.ChoiceGroupName, c.ChoiceValueId }
                   equals new { Specific.ChoiceGroupName, ChoiceValueId = (Int32)Specific.ChoiceValueId } into Specific_join
                 from Specific in Specific_join.DefaultIfEmpty()
                 select new
                 {
                     c.ChoiceGroup.ChoiceGroupName,
                     ChoiceValueId = (Int32?)c.ChoiceValueId,
                     SpecificValueDisplayName = Specific.DisplayName,
                     SpecificValueDescription = Specific.Description,

                 }).ToList();



但在执行它在C#正冬眠我得到了以下错误

but while executing it on n-hibernate in c# i got following error

The method or operation is not implemented

堆栈跟踪是

   at NHibernate.Linq.Visitors.QueryModelVisitor.VisitGroupJoinClause(GroupJoinClause
   groupJoinClause, QueryModel queryModel, Int32 index)
   at Remotion.Data.Linq.Clauses.GroupJoinClause.Accept(IQueryModelVisitor visitor,
   QueryModel queryModel, Int32 index)
   at Remotion.Data.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1
   bodyClauses, QueryModel queryModel)
   at Remotion.Data.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
   at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel
   queryModel, VisitorParameters parameters, Boolean root)
   at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor
   sessionFactory)

任何一个可以请帮我解决这个问题?

can any one please help me to overcome this problem?

推荐答案

在我看来,该LINQ到您在使用Hibernate库是不完整的。某处 NotImplementedException 被抛出。您是否使用了稳定的版本?

It seems to me that the Linq to Hibernate library you're using is incomplete. Somewhere a NotImplementedException is being thrown. Are you using a stable release?

在互联网快速捅说,组加入和选择子查询不被支持。您正在使用您的示例中的组加入,因此例外。具体来说,以下博文:

A quick poke around the internet says that group joins and subqueries in selects are not supported. You're using a group join in your example, hence the exception. Specifically, the following post(s):




  1. http://ayende.com/blog/4083/nhibernate-linq-1-0-released
  2. http://guildsocial.web703.discountasp.net/dasblogce/2009/07/29/LinqToNHibernateJoins.aspx

在NHibernate的3.1源代码,即抛出您的异常神色的方法正是这样的:

In the NHibernate 3.1 source code, the method that is throwing your exception looks exactly like this:

public override void VisitGroupJoinClause(GroupJoinClause groupJoinClause, QueryModel queryModel, int index)
{
    throw new NotImplementedException();
}



一些解决方案建议编写自己的HQL(如原始的SQL),而不是LINQ的语法。

Some solutions suggest writing your own HQL (like raw SQL) instead of the Linq syntax.

这篇关于而使用LINQ to NHibernate的方法或操作未实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:16