<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    blogjava's web log

    blogjava's web log
    ...

    Nhibernate MultiQuery

    構造多個查詢。效果不錯。注意Nhibernate CreateMultiQuery()這個方法
    public void MultiQueryTest(int var)
    {
       ISession session = null;
       session = Class1.GetFactory().OpenSession();
       IList result = session.CreateMultiQuery().Add("from Archives where id>:id")
          .Add("select count(*) from Archives a where id>:id").SetInt32("id", var).List();
       //獲得第一個查詢結果
       IList archives = (IList)result[0];
       long count = (long)((IList)result[1])[0];
    
       //當然也可以session.CreateQuery 構造查詢
        //IList result = session.CreateMultiQuery()
         //    .Add(session.CreateQuery("from Archives where id>:id").SetFirstResult(5).SetMaxResults(10))
        //    .Add(session.CreateQuery("select count(*) from Archives a where id>:id"))
        //    .SetCacheable(true).SetInt32("id", var).List();
        // IList archives = (IList)result[0];
       //long count = (long)((IList)result[1])[0];
    
     }
     
    //helper 
    public class Class1
        {
            private static ISessionFactory factory;
            private static string _mappingAssembly;
     
            static Class1()
            {
     
                _mappingAssembly = ConfigurationManager.AppSettings["EntityAssemblyName"];
                NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
                foreach (string assembly in _mappingAssembly.Split(','))
                {
                    try
                    {
                        cfg.AddAssembly(assembly);
                    }
                    catch (MappingException me)
                    {
                        throw new MappingException("Assembley Could Not Be Loaded: " + assembly, me);
                    }
                }
     
                factory = cfg.BuildSessionFactory();
            }
     
            public static ISessionFactory GetFactory()
            {
                return factory;
            }
         }
    更多精彩關注 http://www.ayende.com/

    posted on 2007-05-12 21:18 record java and net 閱讀(839) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    導航

    常用鏈接

    留言簿(44)

    新聞檔案

    2.動態語言

    3.工具箱

    9.文檔教程

    友情鏈接

    搜索

    最新評論

    主站蜘蛛池模板: 国产免费一区二区三区VR| 国产成人免费午夜在线观看| 拔擦拔擦8x华人免费久久| 亚洲欧美日韩一区二区三区在线| 日本高清在线免费| 亚洲jizzjizz在线播放久| 成年女人看片免费视频播放器| 2020亚洲男人天堂精品| 在线jlzzjlzz免费播放| 国产精品亚洲二区在线| 亚洲国产91精品无码专区| japanese色国产在线看免费| 中文字幕亚洲一区二区va在线| 中文字幕高清免费不卡视频| 亚洲国产精品无码成人片久久| 免费A级毛片无码视频| 亚洲免费黄色网址| 国产免费久久精品久久久| 一区二区视频在线免费观看| 久久亚洲精品中文字幕三区| 91九色视频无限观看免费| 一区二区亚洲精品精华液| 四虎影永久在线高清免费| 国产精品视频全国免费观看| 久久综合图区亚洲综合图区| 又粗又大又黑又长的免费视频| 亚洲国产成人久久精品软件 | 毛片无码免费无码播放| 亚洲国产精品综合一区在线| 免费看国产精品3a黄的视频| 日韩大片免费观看视频播放| 亚洲电影国产一区| 韩国免费三片在线视频| a级毛片免费观看网站| 亚洲成人黄色在线| 免费中文字幕不卡视频| 亚洲91av视频| 国产国产人免费人成免费视频 | 国产亚洲成在线播放va| 亚洲成人午夜在线| 国产成人免费ā片在线观看|