NHibernate删除DAL吗? [英] NHibernate removes DAL?
问题描述
我对吗,使用NHibernate(或任何其他ORM)消除了DAL的必要性吗? 还是不?
Am I right that using NHibernate (or any other ORM) removes the necessity of DAL? Or not?
推荐答案
您需要DAL,问题是您在DAL中做什么.在NHibernate的.NET项目中,我使用了这个组织
You need a DAL, the question is what do you do in the DAL. In a .NET project with NHibernate, I use this organisation
- MyProject.Core.DomainModel:在此项目中,仅.cs和映射文件(.hbm.xml)
- MyProject.Repo:在此类中,您使用NHibernate方法,例如Get,Load,make query....
- MyProject.Service:从这些类中,我调用MyProject.Repo方法
- MuProject.UI:ASP.NET,ASP.NET MVC,Winforms .....
- MyProject.Service.Tests:用于测试服务的所有单元测试
我举一个例子,我想让所有活跃的Employee进行排序.
I give you an example, I'd like get all active Employee and sort them.
在我的UI中,我调用MyProject.Service.EmployeeService.GetActive();.在getGetActive中,我在PyProject.Repo中调用一个函数以获取活跃的员工.当返回结果时(在service方法中),我对Linq进行了订购,并返回了订购的列表.
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.
要恢复,Repo项目要通过NHibernate访问数据库,而服务就是业务.
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 :)
这篇关于NHibernate删除DAL吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!