创建Linq

[db:摘要]

创建Linq-> HQL提供程序(Creating a Linq->HQL provider)

我有一个连接到服务器的客户端应用程序。 服务器使用hibernate进行持久化和查询,因此它有一组带注释的hibernate对象用于持久化。

客户端将HQL查询发送到服务器并获取响应。 客户端具有一组自动生成的对象,这些对象与服务器hibernate对象匹配,以查询结果和基本持久性。

我想支持使用Linq查询以及Hql,因为它使查询类型安全并且更快地构建(在HQL字符串查询中不再有拼写错误)。 我环顾四周,但我看不出如何让它们与我所拥有的相符合。

NHibernate的Linq提供者 - 需要使用NHibernate ISession和ISessionFactory,我没有 LinqExtender - 需要对对象进行大量注释并扩展基类型,过于侵入

我真正想要的是生成的东西给我一个很好的易于处理的结构来构建HQL查询。 我已经阅读了一篇由C#开发人员撰写的关于如何创建自定义提供程序的15页文章中的大部分文章,这非常令人担忧,这主要是因为表达式树的复杂性。

任何人都可以建议实施Linq - > HQL翻译的方法吗? 也许是一个将表达式树清理成更多SQL / HQLish的库。

我想支持select / from / where / group by / order by / join。 不太担心子查询。

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.

最满意答案

我认为没有任何库可以做到这一点。 您可以编写自己的提供商。 有一些工具包可以帮助您编写这样的提供程序。 例如IQToolkit 。 但请注意,编写自己的提供商仍然需要做很多工作。 我不确定这笔投资是否值得。

So I found this library re-linq which is what NHibernate uses to implement its LINQ functionality. Seems to tidy up a lot of the noise around the expression stuff, although there seems to be a fair bit to do to on top to create an implementation.

re-linq

发布者:admin,转转请注明出处:http://www.yc00.com/web/1690546154a367674.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信