使用 Nhibernate 调用存储过程 - 出现异常 无持久化:
这是代码,我如何调用存储过程
ISession session = NHibernateHelper.GetCurrentSession();
IQuery q = session.GetNamedQuery("ps_getProgressBarData1");
var t = q.List();
XML 映射
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ReleaseDAL" assembly="ReleaseDAL">
<sql-query name="ps_getProgressBarData1">
<return alias="ProgressBar" class="ProgressBar">
<return-property name="Tot" column="Tot"/>
<return-property name="subtot" column="subtot"/>
</return>
exec ps_getProgressBarData1
</sql-query>
</hibernate-mapping>
类映射
public virtual Int32 Tot {get { return _Tot; } set { _Tot = value; } }
public virtual Int32 subtot { get { return _subtot; } set { _subtot = value; }}
我遇到异常: No persister for: ReleaseDAL.ProgressBar, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
请告诉我这里有什么问题吗?
谢谢
here is code, how I am calling Stored procedure
ISession session = NHibernateHelper.GetCurrentSession();
IQuery q = session.GetNamedQuery("ps_getProgressBarData1");
var t = q.List();
XML mapping
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="ReleaseDAL" assembly="ReleaseDAL">
<sql-query name="ps_getProgressBarData1">
<return alias="ProgressBar" class="ProgressBar">
<return-property name="Tot" column="Tot"/>
<return-property name="subtot" column="subtot"/>
</return>
exec ps_getProgressBarData1
</sql-query>
</hibernate-mapping>
Class mapping
public virtual Int32 Tot {get { return _Tot; } set { _Tot = value; } }
public virtual Int32 subtot { get { return _subtot; } set { _subtot = value; }}
I am getting exception: No persister for: ReleaseDAL.ProgressBar, ReleaseDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Please tell me what is the issue here?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会收到错误消息,因为您没有将映射文件标记为
嵌入资源
。请首先检查这一点。You could get that error you don't have the mapping file marked as
embedded resource
. Please check that as first thing.好吧,您没有 ProgressBar 的映射(我认为它不是一个实体),所以您可能只需要一个 DTO 作为查询的结果。
因此,您只需将结果映射为标量,并在查询中定义一个转换器。
并在查询方法中:
Well you don't have a mapping for ProgressBar (it's not an entity I suppose), so probably you just want a DTO as a result from the query.
So you just have to map the result as scalars, and in the query define a transformer.
and in the query methode: