Why do I need nhibernate.dll referenced in my asp.net mvc project?
All my data logic is in another data layer project that I reference in my asp.net mvc project.
Now if I call:
CategoryDAO.GetById(1);
Everything works fine.
If I call:
CategoryDAO.GetBlah(1);
VS.NET complains saying
"Error 102: The type 'NHibernate.Criterion.Order' is defined in an assembly
that is not referenced. You must开发者_StackOverflow add a reference to assembly 'NHibernate,
Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'."
If I add nhibernate.dll as a reference in my web project, it works.
Why is this? The logic/code is in my data layer, it is return the same as the call to GetById(1), why do I need to add the reference?
I'm guessing it's because of the lazy-loading that comes build into your objects. NHibernate creates proxy objects that inherit from your class (which is why you need to declare your methods as virtual). I'm guessing the reference is needed because of the proxy objects.
精彩评论