What is the difference between DAO and Data Mapper

Is there a difference between a DAO pattern and a Data Mapper pattern? Is DAO one of the Data Mapper methods?

+4
source share
1 answer

In fact, I would not call the DAO a "template". As I see it, the DAO is pretty much what it is - a โ€œdata access objectโ€ that encapsulates the details of access to a persistent data store and, generally speaking, has nothing to do with the database:

interface IBlogDaoService { Blog GetBlog(long id); void SaveBlog(Blog blog); } 

It is clear that implementations can use either a database (in this case it is quite logical to use a Data Mapper) or a simple mechanism for storing XML files.

On the other hand, the Data Mapper is rather a template that defines the level responsible for translating graphs of objects in memory into a relational structure.

+7
source

All Articles