使用 linq to nhibernate 时未实现该方法或操作

发布于 2024-12-21 04:08:59 字数 2257 浏览 1 评论 0原文

我尝试使用 linq to nhibernate 3 并且我做了以下 linq 查询,

 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# 中的 n-hibernate 上执行它时,我得到了以下错误

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)

有人可以帮助我解决这个问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很酷又爱笑 2024-12-28 04:08:59

在我看来,您使用的 Linq to Hibernate 库不完整。某处抛出了 NotImplementedException。您使用的是稳定版本吗?

在互联网上快速浏览了一下,发现不支持选择中的组连接和子查询。您在示例中使用的是组加入,因此是例外。具体来说,以下帖子:

  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)

在 NHibernate 3.1 源代码中,抛出异常的方法看起来完全像这样:

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

更新:从版本 5.1.x 开始,NHibernate 的 LINQ 提供程序仍然不支持手术。

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文