The repository pattern is used to create a layer between database operations and our business logic. It is one popular pattern used to create enterprise level applications. It restricts us to directly performing operations on the database and helps us to test the code.
The following is the hierarchy of MessageRepository, which handles the operations to the database: