Skip to end of metadata
Go to start of metadata

The common base-class for all repositories is implemented in the sub-project Hotel.Repository. It is a simple generic type with the type of the aggregated instances as type parameter. The generic interface IRepository<T> exposes three methods:

- T Add (T elem);
- T Remove (T elem);
- IQueryable<T> Find ();

Add and Remove return the same instance as was passed as a parameter. This is not very useful in most cases, but can make code more compact in other cases.

Find without any parameters returns all instances in the repository as an IQueryable<T>, which can be queried with Linq. This method is used a lot in the Mixin Hotel app.

A more elaborate discussion (plus some hand-waving) can be found in this digression: Repositories -- sample vs. production.

  • No labels