NHibernate 3版本新特性

2021-07-04 12:30:55 字數 2746 閱讀 3621

在configuration部分新增兩種loquacious-configuration方式:流配置(fluent-configuration)和lambda表示式配置(lambda-configuration)

fluent-configuration顧名思義,使用fluent api配置sessionfactory屬性,提供強型別支援、編譯期錯誤檢查等。你可以通過sessionfactory fluent配置了解詳細資訊。例如使用流配置方式最小配置nhibernate:

var configure = new 

configuration();

configure.sessionfactory()

.named("demo")

.proxy.through()

.integrate

.using()

.connected

.using("connectionstring");

var configure = new 

configuration();

configure.sessionfactoryname("demo");

configure.proxy(p => p.proxyfactoryfactory());

configure.databaseintegration(db =>

);

新增wcfoperationsessioncontext類提供對wcf環境的支援,我們直接配置"current_session_context_class"為"wcf_operation"在wcf環境中應用nhibernate。

var orm = new 

orm.tableperclass();var conf=new

configuration();

//...

在nhibernate 3.0.0版本中,query方式新增了linq支援和強型別查詢api(queryover)兩種查詢方式。

queryover是lambda表示式方式的條件(criteria)查詢,可讀性強且支援property-renaming特性。可以參考queryover in nh 3.0。例如下面查詢name為李永京、按照age降序的person集合:

var query = s.queryover()

.where(p => p.name == "李永京")

.orderby(p => p.age).asc

.list();

var query = session.query().where(o => o.name == "李永京").tolist();
還有其他一些新特性:

重構logging abstraction日誌系統模組:移除對log4net.dll程式集依賴,現在可以用commonlogging或者nlog日誌系統。可以參考using nlog via common.logging with nhibernate。

屬性延遲載入和no proxy關聯特性:具體使用方法可以參考ayende的nhibernate new feature: lazy properties和nhibernate new feature: no proxy associations兩篇博文。它僅支援castle的bytecode-providers,不支援spring.net和linfu**。

對映支援xdocument、system.uri、xmldoc、local & utc datetime型別。

bytecode-providers程式集更新:castle使用2023年11月15號發布的2.5.2正式版本,即castle.core.dll程式集。liufu使用2023年4月5號發布的1.04版本,即linfu.dynamicproxy.dll程式集。

如果從nhibernate2.1.2版本公升級到nhibernate3.0.0版本,需要注意下面改變:

nhibernate3.0.0版本不支援.net3.5以下版本,即.net2.0版本不可以公升級到nhibernate3.0.0版本。

[nh-2392]icompositeusertype.nullsafeset方法簽名改變。

[nh-2199]maps/dictionaries中null值不再不加提示地忽略/刪除。

[nh-1894]sybaseanywheredialect刪除,代之以sybaseasa9dialect。刪除了sybase adaptive server enterprise (ase)方言。

[nh-2251]dialect中的getlimitstring簽名變化。

[nh-2284]刪除了過時的成員。

[nh-2358]datetimeoffset型別現在不再是datetime的替代。

最近一年,網路上出現了一些優秀的nhibernate工具:

hql language service for visual studio:為我們編寫hql查詢提供了智慧型提示和語法驗證檢查功能。

nhibernate profile:視覺化nhibernate效能檢測優化工具。

visual nhibernate:視覺化設計和對映工具。

mindscape nhibernate designer:vs設計工具,類似於ef設計器。

其中hql language service for visual studio是一款開源工具,其他都是商業版本。

dynamicCondition v3版本更新內容

2019 04 09 v3.0.0 新增大量特性。ui公升級,css與js分離。主要更新如下 1.新增使用者全域性配置。見dynamiccondition.js同目錄下的dcconfig.js檔案。通過該檔案可以修改dynamiccondition元件全域性預設配置。沒有該檔案也能正常使用,這樣會使...

Swift 1 2版本新特性

隨著xcode6.3正式版本的推出,swift語言也正式進入1.2版本,那麼1.2版本有什麼新特性呢?來快速了解一下吧。1.速度的提公升 速度的提公升首先體現在對工程中增量的單獨編譯,這使得我們在改動較大的工程的時候,執行速度會得到大幅度的提公升。其次體現在swift自己的執行庫的執行時性的增強。s...

python2 版本 與 3 版本中的區別

目錄unicode編碼 print函式print hello world 2.x版本中格式 print hello world 3.x版本中格式 2.6版本已可以支援新的print 語法 from future import print function print fish panda sep r...