As a side not building solution supporting different provides on top of the linq is way to disaster. Linq and IQueryable
are leaky abstractions – each Linq provider can have its own “features” and limitations. Moreover EF itselfs adds some logic via custom extension methods for IQueryable
(like Include
or AsNoTracking
in EFv4.1). These methods internally converts IQueryable
to ORM specific classes.
If you want to have universal solution you must abandon Linq and add third pattern to form the abstraction. In addition to Repository and Unit of Work patterns you need custom Specification pattern. Generally you will reimplement NHibernate’s Criteria API.