Web Application Data Layer

The Web Application data layer is required to implement the Unit of Work and DataContract Respositories that are defined as interfaces in the Core layer.

The entry point to the Data Layer is the IUnitOfWork implentation. A Unit of Work is essentially a transaction and allows atomic database actions to happen/fail together. It allows for Inserts/Updates etc to be called on the data, but nothing is actually saved until SaveChanges method is called. When the SaveChanges method is called it will apply all the updates at the same time and allows for rollback in event of an error.

For example, if you had a process that inserts a patient appointment record, inserts a calendar entry to the staff member and inserts the appointment letter to a document queue - and one part of this fails, with individual inserts you would be left with a partially updated database. By wrapping up the actions in a Unit of Work you can save all the changes together and roll back the whole thing if there is an error.

The IUnitOfWork object contains a set of Repositories which provide the methods to access/update the data. Repositories allow the data access methods to be broken down into categories rather than having a mega data access class with everything in