yra*_*man 3 c# linq-to-nhibernate
我正在尝试使用 linq 来 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();
Run Code Online (Sandbox Code Playgroud)
但是在 c# 中的 n-hibernate 上执行它时,我遇到了以下错误
The method or operation is not implemented
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪是
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)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?
在我看来,您使用的 Linq to Hibernate 库不完整。某处NotImplementedException被抛出。您使用的是稳定版本吗?
快速浏览互联网说不支持选择中的组加入和子查询。您在示例中使用了组连接,因此例外。具体来说,以下职位:
在 NHibernate 3.1 源代码中,抛出异常的方法如下所示:
public override void VisitGroupJoinClause(GroupJoinClause groupJoinClause, QueryModel queryModel, int index)
{
throw new NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)
更新:从 5.1.x 版开始,NHibernate 的 LINQ 提供程序仍然不支持此操作。
一些解决方案建议编写您自己的 HQL(如原始 SQL)而不是 Linq 语法。
| 归档时间: |
|
| 查看次数: |
12773 次 |
| 最近记录: |