使用无状态会话时 IQuery 的 Enumerable 上出现 NotSupportedException

发布于 2024-08-26 10:32:10 字数 1030 浏览 4 评论 0原文

当尝试在无状态会话的命名查询上使用 Enumerable 方法时,如以下示例所示:

http://www.nhforge.org/doc/nh/en/#batch-statelesssession

我看到一个 NotSupportedException。堆栈跟踪如下:

System.NotSupportedException: Specified method is not supported.
at NHibernate.Impl.StatelessSessionImpl.Enumerable(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.Enumerable()

这是我的代码片段:

IStatelessSession statelessSession = sessionFactory.OpenStatelessSession();
var fileLines = statelessSession.GetNamedQuery("GetLinesByFileId")
.SetInt32("FileIdInput", fileId).Enumerable<FileLineEntity>();

命名查询 GetLinesByFileId 在 hbm 中定​​义如下:

<query name="GetLinesByFileId" cacheable="false" read-only="true">
    <![CDATA[
        from FileLineEntity lineItem where lineItem.FileId=:FileIdInput 
      ]]>
  </query>

关于我在这里可能缺少的内容有什么建议吗?

when trying to use the Enumerable method on a named query, with a Stateless session, as shown in the example at:

http://www.nhforge.org/doc/nh/en/#batch-statelesssession

i am seeing a NotSupportedException. the stack trace is as below:

System.NotSupportedException: Specified method is not supported.
at NHibernate.Impl.StatelessSessionImpl.Enumerable(String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl.Enumerable()

here is a snippet of my code:

IStatelessSession statelessSession = sessionFactory.OpenStatelessSession();
var fileLines = statelessSession.GetNamedQuery("GetLinesByFileId")
.SetInt32("FileIdInput", fileId).Enumerable<FileLineEntity>();

the named query, GetLinesByFileId is defined in the hbm as below:

<query name="GetLinesByFileId" cacheable="false" read-only="true">
    <![CDATA[
        from FileLineEntity lineItem where lineItem.FileId=:FileIdInput 
      ]]>
  </query>

any suggestions on what i maybe missing here?

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

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

发布评论

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

评论(1

请止步禁区 2024-09-02 10:32:10

医生错了。另外,通过查看它,您可以看出它是从 Hibernate (Java) 复制的。

请改用 List 方法。

The doc is wrong. Also, by looking at it you can tell it's copied from Hibernate (Java).

Use the List method instead.

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