什么是数据访问层的好方法吗? [英] What is a good approach for a Data Access Layer?

查看:148
本文介绍了什么是数据访问层的好方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的软件是一个定制的人力资源管理系统(HRMS)使用ASP.NET与Oracle的数据库,现在我们实际上是在移动,使其支持多个租户提供自己的数据库产品。

Our software is a customized Human Resource Management System (HRMS) using ASP.NET with Oracle as the database and now we are actually moving to make it a product that supports multiple tenants with their own databases.

我们的选项:

  1. 使用NHibernate的支持多个数据库和使用面向对象。但是,我们关注相关NHibernate的学习曲线,我们所面临的任何问题。

  1. Use NHibernate to support Multiple databases and use of OO. But we concern related to NHibernate learning curve and any problem we faced.

请广义DAL将继续使用存储过程和使用的工具,将其转换为其他的数据库如SQL Server或MySQL与甲骨文合作。有具有支持单个脚本的多个依赖于数据库的版本相关的风险。

Make a generalized DAL which will continue working with Oracle using stored procedures and use tools to convert it to other databases such as SQL Server or MySql. There is a risk associated with having to support multiple database-dependent versions of a single script.

提供软件即服务(SaaS)和维护我们开展业务的方式。然而,有可可能是谁不想要或信任云或其他的SaaS业务模式的客户端。

Provide the software as a Service (SaaS) and maintain the way we conduct business. However there can may be clients who do not want or trust the Cloud or other SaaS business models.

考虑到这一点,什么是最好的数据访问层技术?

With this in mind, what's the best Data access layer technique?

推荐答案

我会说,NHibernate的是IM pressive初看似乎很复杂的学习。因此,在阅读了约260页的介绍文件迅速,有坚持,我需要在测试应用程序执行的任务后,NHibernate的是真的要走的路。如果你不陶醉与XML映射文件,只需要使用 FluentNHibernate 它允许您使用面向对象的映射您业务域对象。

I would say that NHibernate is impressive at first view and seems very complex to learn. Therefore, after reading the about 260 pages introduction document rapidly, and having insisted on the tasks I needed to perform within the tests applications, NHibernate is really the way to go. And if you're not enchanted with the XML mapping files, just use FluentNHibernate which allows you to use OOP for mapping your business domain objects.

此外,如果你不完全放心与NHibernate和preFER去另一种方式,的企业库4.1(2008年10月)可能要么是一个有用的工具。根据不同的情况,在某些组织中,我都选择了NHibernate的一个混合体 - 企业图书馆的做法。该数据访问应用程序块(DAAB)企业库中是非常容易学习,而且不需要你学习任何东西,但你已经知道。你只需要知道使用什么样的对象,从DatabaseProviderFactory类来创建你的DbConnection从配置文件读取,你可以指定一个默认的数据库。

Furthermore, if you're not completely at ease with NHibernate and prefer going another way, Enterprise Library 4.1 (October 2008) might either be a useful tool. Depending on the situation, in some organizations, I have opted for an hybrid of NHibernate - Enterprise Library approach. The The Data Access Application Block (DAAB) within Enterprise Library is quite easy to learn and doesn't require you to learn anything but what you already know. You just need to know what object to use to create your DbConnection from the DatabaseProviderFactory class to read from your configuration files and you may specify a default database.

至于我的关注,我经常同时使用的NHibernate以及企业库。该DAAB让我如指定每个配置文件,因为我preFER数据库连接参数每个文件只有一个连接。这让我不要了的configs这并没有改变,而只部署另一个连接新的配置文件部署不必要的配置文件。所以,如果你合并一个必须在其他地方连接到其他数据存储新的模块,您无需关心剩下的构建模块,伴随着这一新的DAAB配置文件更新你的模块的DLL软件。

As for my concerns, I often use both NHibernate along with Enterprise Library. The DAAB allows me for example to specify a database connection per configuration file since I prefer to parameter only one connection per file. This allows me not to deploy unnecessarily config files for configs that didn't change at all, and only deploy THE new configuration file for another connection. So, if you merge a new module that must connect somewhere else to another datastore, you build your module without caring about the rest, update your software with your module's DLL along with this new DAAB config file.

至于NHibernate的,不要做一件重要的事情是要摆脱ISessionFactory,当你不再需要它。它是珍贵的实例,所以你要保持它在内存中。你可以做的虽然是序列化配置对象的类(因为它是可序列化),因此应用程序可以建立其配置只有在一些东西变成你的NHibernate的配置文件。再说,我建议你使用NHibernate的默认hibernate.cfg.xml配置文件,这样你就不需要在部署app.config文件,并一次又一次的更新来的时候。

As for NHibernate, an important thing not to do is to get rid of the ISessionFactory when you no longer need it. It is costful to instantiate, so you want to keep it in memory. What you can do though is the serialize your configuration object class (as it is Serializable), so your application can build its configuration only if something changed into your NHibernate config file. Then again, I suggest you use the default hibernate.cfg.xml configuration file for NHibernate, this way you won't need to deploy your app.config file over and over again when updates come.

我希望这有助于!让我知道如果你需要进一步的信息。

I hope this helps! Let me know if you need further information.

这篇关于什么是数据访问层的好方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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