问题描述
因此,我试图从表中执行基本的选择查询以返回行.现在,我有一个对象代表表中的数据,并映射到hbm.xml文件中.据我所知,映射是正确的(这是一个带有自动递增键和字符串值的简单表).
So I'm trying to execute a basic select query from a table to return the rows. Right now I have an object representing the data in the table and is mapped in the hbm.xml file. As far as I know, the mapping is correct (it's a simple table with an auto-incrementing key and a string value).
当我这样做时:
session.CreateSQLQuery("SELECT * FROM db.table").List()
例如,结果查询有效.
for example, the resulting query works.
但是,如果我这样做:
session.QueryOver<MyObject>().List()
结果为空.
推荐答案
通常发生这种情况是因为您的XML文件未标记为项目中的嵌入式资源.
Usually when this happens it is because your XML file is not marked as an embedded resource in your project.
请参阅此处:-
这篇关于CreateSQLQuery可以使用,但是QueryOver不能与NHibernate一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!