The method or operation is not implemented while using linq to nhibernate

随声附和 提交于 2019-12-24 00:58:08

问题


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();

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

The method or operation is not implemented

stack trace is

   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?


回答1:


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 (LINK IS DEAD)

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();
}

UPDATE: As of version 5.1.x, NHibernate's LINQ provider still does not support this operation.

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



来源:https://stackoverflow.com/questions/8494071/the-method-or-operation-is-not-implemented-while-using-linq-to-nhibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!