Generic Repository–Cons

Generic Repository (something like Repository<T>) is a good concept with intention of keeping code DRY, though problematic. Here are a few drawbacks of a generic repository:

  1. It is not always logical to call behaviours Save, Delete, etc on all repositories
  2. Support (logging as an example) requires to know what specific repository was invoked, and not just Repository<T>

Just recently I ran into a log with an exception, where operation on …Repositories.Repository`1.Save(T obj...) failed and there was no way to figure out what repository out of 4 different one actually failed save operation.

No Comments