Database abstraction layer design - Using IRepository the right way?

后端 未结 5 679
日久生厌
日久生厌 2020-12-12 18:36

I\'m in the process of designing my ASP.NET MVC application and I ran across a couple of interesting thoughts.

Many samples I have seen describe and use the Reposito

5条回答
  •  攒了一身酷
    2020-12-12 19:07

    Do people have individual repositorys based on each table (IUserRepository)?

    Yes, this was the better choice for 2 reasons :

    • my DAL is based on Linq-to-Sql (but my DTOs are interfaces based on the LTS entities)
    • the performed operations are atomic (adding is an atomic operation, saving is another one, etc.)

    Do they use a generic IRepository?

    Yes, exclusively, inspired on DDD Entity/Value scheme I created IRepositoryEntity / IRepositoryValue and a generic IRepository for other stuff.

    Do they use a static repository factory?

    Yes and no : I use an IOC container invoked via a static class. Well... we can say it's a kind of factory.

    Note : I designed this architecture on my own and a colleague of mine found it so great that we are currently creating our whole company framework on this model (yes it's a young company). This is definitely something worth trying, even if I feel that frameworks of that kind will be released by major actors.

提交回复
热议问题