本文介绍了使用无状态会话时,IQuery的Enumerable上的NotSupportedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当尝试通过无状态会话在命名查询上使用Enumerable方法时,如以下示例所示:
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/zh/#batch-statelesssession
我看到一个NotSupportedException.堆栈跟踪如下:
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()
下面是我的代码段:
IStatelessSession statelessSession = sessionFactory.OpenStatelessSession();
var fileLines = statelessSession.GetNamedQuery("GetLinesByFileId")
.SetInt32("FileIdInput", fileId).Enumerable<FileLineEntity>();
命名查询GetLinesByFileId在hbm中定义如下:
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?
推荐答案
文档错误.另外,通过查看它,您可以知道它是从Hibernate(Java)复制而来的.
The doc is wrong. Also, by looking at it you can tell it's copied from Hibernate (Java).
请改用List
方法.
这篇关于使用无状态会话时,IQuery的Enumerable上的NotSupportedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!