如何使用LINQ在Where子句中进行NHibernate子查询?

编程入门 行业动态 更新时间:2024-10-28 00:21:24
本文介绍了如何使用LINQ在Where子句中进行NHibernate子查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在where子句中编写一个相关子查询,如下所示:

I'm trying to write a correlated subquery in the where clause like this:

var foo = from d in session.Query<Document>() where true == ( from a in session.Query<ACLEntry>() where a.Id == d.Id || a.Id == null select a.Result ).FirstOrDefault() select d;

预期的SQL输出与此关于SO的未回答的问题非常相似.

我认为Linq语句本身很好,因为我可以使它在我正在制作原型的LinqPad中运行.但是NHibernate向我抛出了这些神秘的错误:

I think the Linq statement itself is fine because I can get it to run in LinqPad where I was prototyping. But NHibernate throws me these mysterious errors:

错误NHibernate.Hql.Parser [[null)]-NoViableAltException(86 @ [])

ERROR NHibernate.Hql.Parser [(null)] - NoViableAltException(86@[])

错误NHibernate.Hql.Parser [[null)]-MismatchedTreeNodeException(72!= 3)

ERROR NHibernate.Hql.Parser [(null)] - MismatchedTreeNodeException(72!=3)

这是NHibernate LINQ提供程序不支持的方案吗?关于如何重组查询以解决该问题的任何想法?

Is this an unsupported scenario with the NHibernate LINQ provider? Any ideas on how I might be able to restructure this query to get around it?

推荐答案

在解析查询的true == ...部分时可能会遇到一些麻烦.

It is probably having some trouble parsing the true == ... portion of the query.

可能想尝试一下,

var foo = from d in session.Query<Document>() where (from a in session.Query<ACLEntry>() where a.Id == d.Id || a.Id == null select a.Result ).FirstOrDefault() select d;

更多推荐

如何使用LINQ在Where子句中进行NHibernate子查询?

本文发布于:2023-10-14 21:32:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492274.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   句中   LINQ   NHibernate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!