命名查询未知
我在 NHibernate 中有一个这样的映射:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="News.BusinessEntity" assembly="News.BusinessEntity" xmlns="urn:nhibernate-mapping-2.2">
<class name="News" table="News">
<property name="NewsId" type="Int64" column="NewsId" />
<property name="NewsTitle" type="String" column="NewsTitle" />
</class>
<sql-query name="Sp_News">
<return class="News" />
exec Sp_News
</sql-query>
</hibernate-mapping>
当我调用 session.GetNamedQuery("Sp_News")
时,我收到以下错误:
Named query not known: Sp_News.
任何帮助将不胜感激。
I have a mapping in NHibernate like this:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping namespace="News.BusinessEntity" assembly="News.BusinessEntity" xmlns="urn:nhibernate-mapping-2.2">
<class name="News" table="News">
<property name="NewsId" type="Int64" column="NewsId" />
<property name="NewsTitle" type="String" column="NewsTitle" />
</class>
<sql-query name="Sp_News">
<return class="News" />
exec Sp_News
</sql-query>
</hibernate-mapping>
When I call session.GetNamedQuery("Sp_News")
I get the following error:
Named query not known: Sp_News.
Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将 .hbm.xml 文件的 Build Action 属性设置为 Embeded Resource 即可解决该错误
the error was solved just by setting the Build Action property of .hbm.xml file to Embeded Resource
如果映射文件不以 .hbm.xml 结尾,则会引发相同的错误。
我不小心重命名了映射文件并删除了 .hbm。从名字上看,把它放回去为我解决了这个问题。
The same error is thrown if the mapping file doesn't end with .hbm.xml.
I have accidentally renamed a mapping file and dropped the .hbm. from the name, putting it back solved this issue for me.