业务对象DAL设计对象、业务、DAL

2023-09-03 13:27:00 作者:伪汉子!

在设计业务对象我试图写数据访问层的几种不同的方法。有些人制定了比别人好,但我一直觉得必须有一个更好的方式。

When designing business objects I have tried several different methods of writing the data access layer. Some have worked out better than others but I have always felt there must be a "better" way.

我真的只是想看到的人都处理的DAL在不同情况下的不同方式以及如何技术工作或没有工作的opinon。

I would really just like to see the different ways people have handled the DAL in different situations and their opinon of how the technique worked or didn't work well.

推荐答案

我一直倚重的比利·麦卡弗蒂的NHibernate的最佳实践文章/样品code 为许多Web /应用程序的WinForms现在。这是一个奇妙的书面文章,将为您提供一个良好的固体样品的架构 - 除了教你基本NHibernate和TDD。他试图给你他的架构和设计决策的概述。

I've relied heavily on Billy McCafferty's NHibernate Best Practices article / sample code for many Web / WinForms applications now. It's a wonderfully written article that will provide you with a good solid sample architecture -- in addition to teaching you basic NHibernate and TDD. He tries to give you an overview of his architecture and design decisions.

他创建使用通用DataAccessObjects可以扩展为每个域对象的一个​​非常优雅的DAL - 它非常松耦合的BL使用接口和一个DAOFactory。我建议在看BasicSample第一,尤其是如果你以前没有合作过NHibernate的。

He creates a very elegant DAL using generic DataAccessObjects which you can extend for each domain object -- and its very loosely coupled to the BL using interfaces and a DAOFactory. I would recommend looking at the BasicSample first, especially if you haven't worked with NHibernate before.

请注意,这篇文章在很大程度上依赖于NHibernate的,但我觉得一般的方法就可以很容易地修改,以适应其他奥姆斯。

Note, this article relies heavily on NHibernate, but I think the general approach it could be easily altered to suit other ORMs.