使用 linq to nhibernate 时未实现该方法或操作
我尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您使用的 Linq to Hibernate 库不完整。某处抛出了
NotImplementedException
。您使用的是稳定版本吗?在互联网上快速浏览了一下,发现不支持选择中的组连接和子查询。您在示例中使用的是组加入,因此是例外。具体来说,以下帖子:
http://guildsocial.web703.discountasp.net/dasblogce/2009/ 07/29/LinqToNHibernateJoins.aspx(LINK IS DEAD)在 NHibernate 3.1 源代码中,抛出异常的方法看起来完全像这样:
更新:从版本 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):
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:
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.