What specific issue does the repository pattern solve?

后端 未结 7 1127
自闭症患者
自闭症患者 2020-12-12 12:55

(Note: My question has very similar concerns as the person who asked this question three months ago, but it was never answered.)

I recently started working

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-12 13:20

    You're right,in those simple cases the repository is just another name for a DAO and it brings only one value: the fact that you can switch EF to another data access technique. Today you're using MSSQL, tomorrow you'll want a cloud storage. OR using a micro orm instead of EF or switching from MSSQL to MySql.

    In all those cases it's good that you use a repository, as the rest of the app won't care about what storage you're using now.

    There's also the limited case where you get information from multiple sources (db + file system), a repo will act as the facade, but it's still a another name for a DAO.

    A 'real' repository is valid only when you're dealing with domain/business objects, for data centric apps which won't change storage, the ORM alone is enough.

提交回复
热议问题