NHibernate 3.1 migration problem with Linq

拈花ヽ惹草 提交于 2019-12-10 18:55:16

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5939864/nhibernate-3-1-migration-problem-with-linq

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!