Monday, 15 April 2013

visual studio - 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 refer to in my asp.net mvc project.

Now if I call:

  CategoryDAO.GetById (1);  

Everything works fine

If I call:

  category DAO.GetBlah (1);  

VSNT is complaining

  "Error 102: Type 'NHibernate.Criterion.Order' is defined in an assembly that is not referenced. Assembly "NHibernate, version = 2.1.2.4000, culture = neutral, publicKeyToken = aa95f207798dfdb4". " 

If I use nhibernate.dll as a reference in my web project I add it in, so it works.

Why is that so? The logic / code is in my data level, it gets back to GetById (1) as the call, why do I need to add context?

I guess due to lazy-loading which is created in your objects. Creates a NHibernate proxy object that passes your class (This is why you need to declare your methods virtual). I'm guessing that the proxy object requires reference.


No comments:

Post a Comment