EasyBudget – Repository Models

Repository Models

Back to Notebook

Class Diagrams

Repository Layer Classes Interaction with UnitOfWork Depicted

Sequence Diagram

 

The Repository pattern allows us to separate the actual mechanics of reading and writing to a database so that we can isolate that part of an application’s code. This aids in Unit Testing and allows us to avoid repeated code, which is always a good thing.

The Repository assembly contains an interface, ISystemRepository, that defines the properties and methods required of a valid ISystemRepository instance. In this case, we are using a repository class specific to Sqlite, but we could change this to an Entity Framework based repository class where we work with a DbContext instead of a database connection.

The repository class contains basic CRUD methods for the objects, and some special-case methods used in parts of the application. No error trapping is performed at this level, where it’s preferred to have the UnitOfWork class trap and notify the calling class that an error has occurred.

Back to Notebook