Dropthings 2.6 數據訪問使用了ado.net data model

dropthings 2.6中修改比較大的是數據訪問層的修改,我們放棄了使用Linq2SQL Class,而是使用了ADO.NET Data Model。基本上Omar重新寫了dropthings.DataAccess的代碼。

ADD: Both VS 2008 and VS 2010 Solution files.
CHANGE: Linq to SQL to Entity Framework and Linq to Entities. New project: Dropthings.Data
CHANGE: Data Access unit tests changed to test new.
CHANGE: Remove all Subsystem stuff. Make the repository calls simpler.
ADD: Dropthings.Facade.Test which now has complete integration test to test facade operations.
REMOVE: Linq to SQL based entities, Data Access Layer.

先看一下整個project的改變:

 

新的接口IDatabase的代碼:

 

整個抽象出來的接口比起原來的更加簡單,這種結構留給Business層面處理的代碼就更加少了。。比如原來的一個Insert方法如下:

 

那麼在Business層我們需要使用Action這個委託。。。。。現在使用ADO.NET Data ModelBusinessInsert方法就是直接操作某個實體對象了(EntityObject)

 

再來對比下Insert方法的具體實現代碼:

 

上面是原來的使用linqtosql class實體時的方法,下圖是現在的方法:

 

 

整個查詢的方法也完全重寫寫了,這樣在Repository部分的查詢也會更加簡單和比較簡潔。

性能方面我沒去測試到底快了多少。下面是前後的類圖對比:

 

你可以從http://code.google.com/p/dropthings/downloads/list

這裏下載2.5.52.6.1版本來對比它的數據訪問的變化。

如果有問題請給我留言。。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章