With re-linq, it's now easier than ever to create full-featured LINQ providers.
Yes, you've heard that before. But re-linq is the real thing:
- Instead of the IQueryable expression tree, re-linq gives you an abstract syntax tree that resembles the original LINQ query expression (the one using the from, where etc. keywords).
- This works even when the original query was not a query expression, but a sequence of method invocations of Where(), Select() etc.
- You can easily extend or modify quieries using this representation in your application, directly or via a Specification framework.
- In the process, re-linq gets rid of everything that IQueryable puts between you and your desired target query language:
- The structure is simplified (e.g., SelectMany is transformed back to multiple from-sources).
- Transparent identifiers are removed.
- Sub-queries are identified and can be handled as such.
- Expressions are evaluated up-front wherever possible.
- Special method calls inserted by Visual Basic are "normalized" so that they are handled implicitly, except if you choose to handle them differently.
- re-linq handles even the most complex LINQ query expression, including joins, groups and nested queries.
- re-linq gives you the tools to easily create your own provider, including:
- A set of visitors that you just implement for your transformation.
- A registry for translating methods to specific expressions in the target query language (like string methods, or ICollection.Contains).
- A mechanism to specify eager fetching for related objects or collections that will automatically create the required queries.
- re-linq is completely agnostic of the target query language. You can use it to create any dialect of SQL as well as other query languages such as XQL or Entity SQL. Currently, the NHibernate project uses re-linq to create HQL ASTs.
Depending on the differences between LINQ and the target query language you want to address, there is probably still a major piece of work ahead of you. But with re-linq this is about as simple as it can be: just what you thought was ahead of you before you discovered the internals of IQueryable, and then some more help.
There's one more potential advantage: The remaining effort is probably mostly in the semantic transformation from LINQ to the target query language, especially in cases where the target language does not support certain LINQ constructs (like sub-queries or LINQ group joins). Also, certain optimizations need to be made, e.g. in order to avoid the select n+1 problem
via eager fetching
. In many cases, the necessary transformations are similar between various target languages. re-linq allows you to do these transformations in its own query model representation, before you actually translate to the target language. These transformations can be shared between different LINQ providers via the re-motion contrib repository.
re-linq is part of the re-motion project. See the project home page
for more interesting libraries, such as re-mix
Source Code and Binaries
The most current source code of re-linq is available from our Subversion repository at https://svn.re-motion.org/svn/Remotion/trunk/Relinq/
Weekly builds are now automatically uploaded to CodePlex. Note that due to the goodness of TDD, weekly builds are generally considered stable and we do often use those in production. However, if you need a bug fix you will have to upgrade to a newer version. Hotfixes are only produced for release versions (even/odd scheme: release versions have even minor version numbers, such as the upcoming 1.14.0, and hotfixes will be numbered 1.14.1, 1.14.2 etc.).
Weekly builds are no longer uploaded to http://www.re-motion.org/builds
. CodePlex's Downloads-section is now the only source of truth for re-linq's binary drops.
Builds contain the re-linq's source code documentation as CHM file.ContributingNew:
We now have official contribution practices documented: Contributing to re-linq