zoukankan      html  css  js  c++  java
  • 【NHibernate】HQL入门

    在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
  • 相关阅读:
    再见OI,AFO
    时间复杂度
    NOIP真题:矩阵取数问题
    [USACO12FEB]附近的牛Nearby Cows
    合唱队
    子串
    ZJOI2010基站选址
    分治FFT学习笔记
    「HAOI2018」染色
    「SDOI2015」序列统计
  • 原文地址:https://www.cnblogs.com/viewcozy/p/4641021.html
Copyright © 2011-2022 走看看