[英]The method or operation is not implemented while using linq to nhibernate
我試圖使用linq來休眠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)
誰能幫助我克服這個問題?
在我看來,您正在使用的Linq to Hibernate庫是不完整的。 引發NotImplementedException
某個地方。 您使用的是穩定版本嗎?
在互聯網上快速瀏覽一下發現,不支持選擇中的組聯接和子查詢。 您在示例中使用的是組聯接,因此是例外。 具體來說,以下職位:
在NHibernate 3.1源代碼中,引發異常的方法如下所示:
public override void VisitGroupJoinClause(GroupJoinClause groupJoinClause, QueryModel queryModel, int index)
{
throw new NotImplementedException();
}
更新 :從5.1.x版本開始,NHibernate的LINQ提供程序仍然不支持此操作。
一些解決方案建議編寫自己的HQL(例如原始SQL),而不是Linq語法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.