從本質上來說iBATIS不能算是一種orm工具,只是一個DataMapper。
我們甚至可以把它看成一個SQL產生工具,也就是對 ADO.net 中 IDbCommand 和 IDataParameter 的一個XML格式化的配置,SqlMap是IbatisNet 的一個亮點。
從使用上看,IbatisNet 也具有ORM的某些特點,很方便的在實體和資料庫之間相互操作
從構架上看,IbatisNet 不像NHibernate 享有資料庫的完全控制權,也給我們擴充提供餘地
從效能上看,IbatisNet 應該比ORM有優勢,而且SQL語句是開放的,可最佳化的。
什麼時候使用IbatisNet 什麼時候使用NHibernate
我們看看IbatisNet 作者的原話
If you are starting a new project and you're in full control of your object model and database design, NHibernate is a good choice of O/R tool.
If you are accessing any 3rd party databases (e.g. vendor supplied), or you're working with a legacy database, or even just a really poorly designed database, then an O/R mapper might not be capable of handling the situation. That's were an SQL Mapper comes in handy
既然寫的是開發指南,我就不過多的涉及IbatisNet 實現原理
總體上講IbatisNet 是我比較喜歡一套構架 已經在幾個實踐項目應用過
如果用Castle的ICO作為業務容器 和用Castle的交易處理機制,將會有珠聯壁合的感覺
先放上一個完整的Demo
===============================================================
IBatisNetDemo
DateBase.sql 為示列資料庫角本
將為你建立 Demo資料庫和 一個Artical表
Library檔案夾 包括用到的Castle 和 IBatisNet Dll組件
如果引用出錯 請手動重新添加
Castle 的版本是1.1.0.0
IBatisNet 的版本為 1.6.1.0
Business.Model檔案夾 業務實體
Business檔案夾 商務邏輯
Dao檔案夾 IBatisNet Dao項目
Web檔案夾 Web2.0項目
=================================================================
由於沒有去官網去看更新文檔,就拿手上早期的版本了
接下來詳細講解
To be Continued