NotSupportedException on IQuery's Enumerable when using statelesssession

梦想的初衷 提交于 2019-12-11 08:36:42

问题


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?


回答1:


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

Use the List method instead.



来源:https://stackoverflow.com/questions/2503445/notsupportedexception-on-iquerys-enumerable-when-using-statelesssession

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!