Creating a Linq->HQL provider

Posted by Mike Q on Stack Overflow See other posts from Stack Overflow or by Mike Q
Published on 2010-06-16T10:40:58Z Indexed on 2010/06/16 11:42 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

Hi all,

I have a client application that connects to a server. The server uses hibernate for persistence and querying so it has a set of annotated hibernate objects for persistence.

The client sends HQL queries to the server and gets responses back. The client has an auto-generated set of objects that match the server hibernate objects for query results and basic persistence.

I would like to support using Linq to query as well as Hql as it makes the queries typesafe and quicker to build (no more typos in HQL string queries). I've looked around at the following but I can't see how to get them to fit with what I have.

  • NHibernate's Linq provider - requires using NHibernate ISession and ISessionFactory, which I don't have
  • LinqExtender - requires a lot of annotations on the objects and extending a base type, too invasive

What I really want is something that will generate give me a nice easy to process structure to build the HQL queries from. I've read most of a 15 page article written by one of the C# developers on how to create custom providers and it's pretty fraught, mainly because of the complexity of the expression tree.

Can anyone suggest an approach for implementing Linq -> HQL translation? Perhaps a library that will the cleanup of the expression tree into something more SQL/HQLish.

I would like to support select/from/where/group by/order by/joins. Not too worried about subqueries.

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about hql