Repository and Unit of Work patterns - How to save changes

后端 未结 5 1711
旧巷少年郎
旧巷少年郎 2021-01-30 05:28

I\'m struggling to understand the relationship between the Repository and Unit of Work patterns despite this kind of question being asked so many times. Essentially I still don\

5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 06:05

    normally, repositories handle all reads, and unit-of-work handles all writes,but for sure you can handle all reads and writes by only using one of these two (but if only using repository pattern, it will be very tedious to maintain maybe 10 repositories,more worse,maybe result in inconsistent reads and writes be overwritten), advantage of mix using both is ease of tracing status change and ease of handling concurrency and consistent problems. for better understanding,you can refer links: Repository Pattern with Entity Framework 4.1 and Parent/Child Relationships and https://softwareengineering.stackexchange.com/questions/263502/unit-of-work-concurrency-how-is-it-handled

提交回复
热议问题