Am I right that using NHibernate (or any other ORM) removes the necessity of DAL? Or not?
I was trying to think of how to answer this question but the answer is NO, it doesn't remove the neccesity of a DAL rather than becomes part of that DAL, what you were doing before no doubt was having access objects which called either sql code build in code or was calling stored procs.
It was then constructing say a Bill business object with data perhaps from multiple tables and then returning that. It was a lot of hard work and usually involved maintainance by itself.
NHibernate takes the heavy lifting work out of this task (and does other things) but you still may want "Manager" classes as part of the data access layer to do manipulation before objects are returned etc.
So allthough I'm doing a terrible job of explaining it, NHibernate doesn't remove the need for a DAL it just changes what your DAL is made up of.
You need a DAL, the question is what do you do in the DAL. In a .NET project with NHibernate, I use this organisation
I give you an example, I'd like get all active Employee and sort them.
in my UI, I call MyProject.Service.EmployeeService.GetActive(); in getGetActive, I call a function in PyProject.Repo to get active employee. When I have the result back (in the service method), I do an order with Linq and return the list ordered.
To resume, the Repo project, it's access DB via NHibernate and Service it's the business.
It's my opinion, it's like this I do it's may be not the best way, not the only way, but it's my way :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With