DAO和存储库之间有什么区别 [英] what is the difference between the DAO and repositery
本文介绍了DAO和存储库之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DAO和repositery之间有什么区别,它们是如何在项目中使用的。
以及DAL,DAO,Repositery之间的关系是什么。
what is the difference between the DAO and repositery , how they are used in the project..
and also what is the relation between DAL,DAO,Repositery.
推荐答案
DAO是数据持久性的抽象。存储库是对象集合的抽象。
DAO将被认为更接近数据库,通常以表为中心。存储库将被视为更接近域,仅处理聚合根。可以使用DAO实现存储库,但是你不会做相反的事情。
此外,存储库通常是一个较窄的接口。它应该只是一个对象的集合,具有Get(id),Find(ISpecification),Add(Entity)。类似于Update的方法适用于DAO,但不适用于存储库 - 使用存储库时,通常会通过单独的UnitOfWork跟踪对实体的更改。
看起来确实如此通常看到实际上称为存储库的实现更多的是DAO,因此我认为它们之间存在一些混淆。
请参阅以下链接了解更多信息
http://msdn.microsoft .com / zh-CN / magazine / dd419654.aspx [ ^ ]
http://www.codeinsanity.com/ SystemMessages / FileNotFound.aspx [ ^ ]
http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/ [ ^ ]
http://devlicio.us/blogs /casey/archive/2009/02/20/ddd-the-repository-pattern.aspx [ ^ ]
DAO is an abstraction of data persistence. Repository is an abstraction of a collection of objects.
DAO would be considered closer to the database, often table-centric. Repository would be considered closer to the Domain, dealing only in Aggregate Roots. A Repository could be implemented using DAO''s, but you wouldn''t do the opposite.
Also, a Repository is generally a narrower interface. It should be simply a collection of objects, with a Get(id), Find(ISpecification), Add(Entity). A method like Update is appropriate on a DAO, but not a Repository - when using a Repository, changes to entities would usually be tracked by separate UnitOfWork.
It does seem common to see implementations called a Repository that are really more of a DAO, and hence I think there is some confusion about the difference between them.
see below links for more info
http://msdn.microsoft.com/en-us/magazine/dd419654.aspx[^]
http://www.codeinsanity.com/SystemMessages/FileNotFound.aspx[^]
http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/[^]
http://devlicio.us/blogs/casey/archive/2009/02/20/ddd-the-repository-pattern.aspx[^]
这篇关于DAO和存储库之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文