What's the difference between DAO and Data Mapper

拈花ヽ惹草 提交于 2019-11-30 15:30:29

I wouldn't actually call DAO a "pattern". As I see it, DAO is pretty much what it is -- a Data Access Object", which encapsulates the details of accessing 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's clear that implementations can use either DB (in which case it's quite logical to use a Data Mapper), or simple XML file storage mechanism.

The Data Mapper on the other hand is more of a pattern, which defines a layer responsible for translating in-memory graphs of objects to the relational structure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!