添加了嵌入式资源映射文件 - 类未映射
在我的 asp.net mvc 应用程序中,我使用 nhibernate 3.2 作为 ORM。我的目录结构如下 ..\Models\Persons 中包含 User.cs 和 OtherClass.cs 以及 ..\Mapping 文件 hibernate.xml,Persons.xml 我添加了映射文件作为嵌入资源,并且在应用程序代码中我
Assembly assembly = Assembly.GetExecutingAssembly();
config.AddAssembly(assembly);
sFactory = config.BuildSessionFactory();
尝试运行简单hql 查询
From User up WHERE up.Password=admin AND up.Login=admin
但我仍然收到错误:
NHibernate.DLL 中发生了“NHibernate.Hql.Ast.ANTLR.QuerySyntaxException”类型的第一次机会异常
用户未映射 [ FROM User up WHERE up.Password=admin AND up.Login=admin]
我不知道我做错了什么。我将不胜感激任何帮助。
In my asp.net mvc application I'm using nhibernate 3.2 as ORM. I have catalogue structure like
..\Models\Persons with User.cs and OtherClass.cs in it and also ..\Mapping with files hibernate.xml,Persons.xml I added mapping files as embeeded resources and in code of application I have
Assembly assembly = Assembly.GetExecutingAssembly();
config.AddAssembly(assembly);
sFactory = config.BuildSessionFactory();
I tried to run simple hql query
From User up WHERE up.Password=admin AND up.Login=admin
but I still get an error:
A first chance exception of type 'NHibernate.Hql.Ast.ANTLR.QuerySyntaxException' occurred in NHibernate.DLL
User is not mapped [ FROM User up WHERE up.Password=admin AND up.Login=admin]
I can't get an idea what I'm doing wrong. I'd appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在创建后通过检查 sessionfactory 属性来检查映射是否已加载吗?
Can you check if the mappings are loaded by inspecting the sessionfactory properties after creation?