NHibernate 删除了 DAL? [英] NHibernate removes DAL?

查看:26
本文介绍了NHibernate 删除了 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:用于测试服务的所有单元测试

我举个例子,我想获取所有活跃的员工并对其进行排序.

I give you an example, I'd like get all active Employee and sort them.

在我的用户界面中,我调用 MyProject.Service.EmployeeService.GetActive();在 getGetActive 中,我调用 PyProject.Repo 中的一个函数来获取活跃员工.当我返回结果时(在服务方法中),我使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆