Repository<T>, RepositoryInMemory<T>, RepositoryQuerable

Feb 18, 2010 at 2:00 AM


I've put in a bit of work into the Repository pattern and just wanted your feedback.


Here is an overview

RepositoryQueryable: Provides core query abilities against your repository ( table - real or in-memory ).

Supports functions: 

Min, Sum, Max, Avg, Count, Distinct, GroupBy, Any, ToTable methods

NOTE: All these methods are overloaded with columname, and ICriteria objects.


Repository<T>: Extends RepositoryQueryable, also base class for providing CRUD (Create, Retrieve/Get, Update, Delete ) methods on any entity.

Supports functions:

Create, Get, Find, Update, Delete, Recent, Find

NOTE: RepositorySql<T> extends this but leaves the Create(), Update(), and RowMapper for you to implement for your entity


RepositoryInMemory<T>: Provides exactly the same functionality as Repository<T> but everything is stored In-Memory as a DataTable.

Support functions:

Same as Repository<T>

NOTE: This is very useful for unit-testing.


RepositoryVersionable<T>: Provides versioning on top of any Repository<T> implementation.

NOTE: This is a decorator that encapsulates any IRepository<T>. The latest version of an entity always has the same Id ( primary key ).


Dec 8, 2010 at 6:29 PM
Edited Dec 10, 2010 at 3:22 PM

Updated question...

Would there be an easy way to design the library to allow the Entity Id be any type we choose?

Would there be an easy way to design the library to allow the Entity to share database contexts?