首页 > Web开发 > 详细

【NHibernate】HQL入门

时间:2015-07-12 17:10:00      阅读:253      评论:0      收藏:0      [点我收藏+]

 

在NHibernate 中 HQL 可以帮我们转成最终依赖数据库的查询脚本;

语法也甚是强大,适配主流数据库, HQL不支持union,要想取多个表数据可以做两次单独查询。

 

 

 IQuery query =
                NHibernateHelper.OpenSession()
                    .CreateQuery(
                        @"select p from Product as p,Product as pp where p.Name=pp.Name");
                       
            IList result = query.List();
            IEnumerator enu = result.GetEnumerator();
            while (enu.MoveNext())
            {
                object[] obj = (object[])enu.Current;     
            }

 

HQL

select p from Product as p,Product as pp where p.Name=pp.Name

MSSQL

NHibernate: select product0_.Id as Id0_, product0_.Name as Name0_, product0_.Category as Category0_, product0_.Discontinued as Disconti4_0_ from Product product0_, Product product1_ where product0_.Name=product1_.Name

 

【NHibernate】HQL入门

原文:http://www.cnblogs.com/viewcozy/p/4641021.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!