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版本来对比它的数据访问的变化。

如果有问题请给我留言。。

 

 

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