Project Description
Oridea.Data.Fetching is a class library that consists of a few wrappers over the LINQ's IQueryable interface narrowing its scope to fetching, ordering, and paging operations. It is designed for use in the implementations of the Repository pattern.

Solving the IQueryable exposure dilemma
There is much debate over the Internet on whether to expose generic IQueryable<T> objects in public methods of Repository pattern implementations or not. Some development teams tend to avoid such exposure, thus favouring public methods returning normal collections with fetched data, e.g. ReadOnlyCollection<T>. However, this leads to needlessly complicated code in many situations, for example, if there is a query to find a customer from the database by name, then there might be few different methods doing this: one FindByName(name), another CountByName(name) : int, may be yet another FindByName(name, pageNumber, rowsInPage). Of course, they might use one same private method returning an IQueryable<T>, so as to avoid duplicating the query many times. Nevertheless, there is a better approach.

The Oridea.Data.Fetching library contains a very simple way of narrowing the scope of IQueryable<T> to three set of operations: fetching, ordering, and paging. The ordering is implemented in a special fashion that avoids usage of OrderBy and ThenBy methods by the calling code. Rather, methods use OrderingSequence -- a sequence of Expression<T, TKey> instances that is capable of applying itself on an IQueryable<T> later on.

The source code contains the Oridea.Data.Fetching.Example project that demonstrates a possible usage of the Oridea.Data.Fetching library.

Last edited Aug 1, 2011 at 6:40 AM by Sklyarevsky, version 3