NHibernate 3.1 与 Linq 的迁移问题
我面临着从 NHibernate 2.1.2 + Fluent 1.0 迁移到 NHibernate 3.1 + Fluent 1.2 的问题:
曾经可以工作:
List<Order> orders = session.Linq<Order>()
.Where(o => o.OrderLines.Any(ol => printStatuses.Contains(ol.PrintStatus)))
.ToList();
不再工作
List<Order> orders = session.Query<Order>()
.Where(o => o.OrderLines.Any(ol => printStatuses.Contains(ol.PrintStatus)))
.ToList();
我们收到以下错误:
“无法加载类型 o.OrderLines< /strong> 可能的原因:未加载或未指定程序集。”
OrderLines是类Order的集合属性,输入IList
NHibernate似乎无法获取完全限定的类名那个集合。不过,查看会话工厂,我们可以看到 collectionRolesByEntityParticipant 字典包含类 OrderLine 的键,其字典值指向 Order.Orderlines >。
有人解决这个问题了吗?
编辑:
PS:如果您想知道,我们使用自动映射。
I am facing a issue regarding the migration from NHibernate 2.1.2 + Fluent 1.0 to NHibernate 3.1 + Fluent 1.2 :
Used to work :
List<Order> orders = session.Linq<Order>()
.Where(o => o.OrderLines.Any(ol => printStatuses.Contains(ol.PrintStatus)))
.ToList();
Don't work anymore
List<Order> orders = session.Query<Order>()
.Where(o => o.OrderLines.Any(ol => printStatuses.Contains(ol.PrintStatus)))
.ToList();
We get the following error :
"Could not load type o.OrderLines. Possible cause: the assembly was not loaded or not specified."
OrderLines is a collection property of the class Order, typed IList<OrderLine>
NHibernate seems to not be able to get the fully qualified class name of that collection. Though, looking at the session factory, we can see that collectionRolesByEntityParticipant dictionary contains a key for the class OrderLine with a dictionary value pointing to Order.Orderlines.
Has anyone solved this ?
EDIT :
PS : We use automapping in case you wonder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就像 @cremor 提到的那样,这可能不是 nhibernate 或您的应用程序的问题。我遇到了同样的问题。如果您转到“异常”对话框 (
Ctrl+Alt+E
),您可能已针对所有“公共语言运行时异常”选中“抛出”。当它们被检查时,每次抛出异常时,Visual Studio 都会中断调试器,即使它是由 try catch 处理的。通常,当您依赖于您不拥有/控制的程序集时,您仅引用 dll,并且没有 pdb 调试文件的副本。 Visual Studio 不知道如何闯入调试器,除非它具有 pdb 文件。TL;DR - 删除 NHibernate.pdb、Iesi.Collections.pdb、Nhibernate.ByteCode.Castle.pdb 文件,Visual Studio 将不会闯入调试器并继续运行。
Like @cremor mentioned, this likely isn't a problem with nhibernate or your app. I ran into the same issue. If you go to the Exceptions Dialog box (
Ctrl+Alt+E
) you probably have "throw" checked for all "Common Language Runtime Exceptions". When they are checked, visual studio will break into the debugger everytime an exception is thrown, even if it is handled by a try catch. Normally when you have a dependency on an assembly you don't own/control, you only reference the dll and you don't have a copy of the pdb debugging files. Visual Studio doesn't know to break into the debugger unless it has the pdb files.TL;DR - Delete the NHibernate.pdb, Iesi.Collections.pdb, Nhibernate.ByteCode.Castle.pdb files and visual studio won't break into the debugger and will keep chugging along.