Reputation: 11
I am new to repository pattern. Can anyone help me on how to create repository pattern & service for 2 tables.
Eg. I have a User Creation screen which have user information and multiple role details. Both data will inserted in a different table. For this scenario how i can create a repository pattern and how to call it.
Note : I am using ADO.Net for the DAL.
Thanks.
Upvotes: 0
Views: 1279
Reputation: 3973
When using the repository pattern the repositories will mirror the structure of the business entities. So if the User has a child collection of UserRoles the business code would interact with a UserRepository which would then interact with a UserRoleRepository class. Each repository class would be responsible for persisting and retrieving the data for its respective business entity. incidentally one of the benefits of the repository pattern is that the structure of the tables in the database does not necessarily have to mirror the structure of the business entities. Also, I would recommend using the Dependency Inversion Principle and Dependency Injection with the business logic code when it interacts with the repositories
Upvotes: 1