ASP.NET MVC using the Repository Pattern

前端 未结 6 764
天涯浪人
天涯浪人 2021-02-05 20:41

Currently im using EF and using its datacontext directly in all of my actions, but since i started reading about loose coupling and testability im thinking that thats not the be

6条回答
  •  既然无缘
    2021-02-05 21:23

    ADO.NET connection pooling will be managing the connections behind-the-scenes. It basically won't matter at all how many different entities (and therefore Repositories with their own context) you use; each DB operation will be taking connections from the same pool.

    The reason for the repository is to enable you to abstract/replace the way the entities are being created for testing, etc. The entity objects can be instantiated like normal objects without the Context's services, so the test repo would do that for the test data

提交回复
热议问题