Linq版N层架构(拿来主义系列)1 -鬼域马
近一年来浸在linq的学习氛围中,但是工作的大环境中用不到, 鬼域马也很疑惑为什么这么好的技术为什么工作环境中不用. 总之杯具了!这不不耽误我的成长, 嘿嘿. 鬼域马暂时没什么创新的东西,只是巧妙的组合现有的东西借了园子大牛们文章里很多东西,可以说是拿来主义者.如果有借鉴到大牛们的想法没有报告的请见谅 有一点要说明这里暂时介绍web Framework民用用法。 先搭一个基本骨架. -Comm : 框架通用类的或辅助类 -DAL : 数据库(linq to Sql) 或者 其他Service -Model : 实体 , 用于层级间传递数据 -BLL : 业务 ,对于业务逻辑的处理 -UI : 界面 ,界面展示
鬼域马想要的框架描述: 尽量 强类型的 静态、编译检查。易于拓展, 良好容错能力、稳定、开发效率高、etc.。还有什么?大家也说说。 上面的骨架看着有点单薄,能开发出我想要的框架吗?不管你们信不信,我反正做出来。


这不是违背了三层架构理念吗?有人会说鬼域马你错了,鬼域马越发觉得这 应该这样对数据筛选。请看三层架构的概念 “ 
三层架构(3-tier application) 通常意义上的三层架构就是将整个业务应用划分为:表现层(UI)、业务逻辑层(BLL)、数据访问层(DAL)。区分层次的目的即为了“高内聚,低耦合”的思想。 “ 

为了拓展性.

加个 partial关键字 固定的代码就可代码生成器搞定了 有很多公司使用代码生成器 特殊搭方法 手工添加。 ------------------------------------------------------------------------------------------  这里用SqlMetal 生成数据库映射对象代码。 实体类 与DataContext分成两个类库 --实体类(model层)主要在各层间传输数据 --DataContext (DAL) 数据库访问


------------------------------------------------------------------------------------- 

每个业务类继承它就可以 this.db.Value.Products;访问数据了  使用 简单工厂可以解决 让对象更容易调配
骨架就这样吧。下回再说其他的比如 DAL层 的改造 comm通用类写什么东西比较, 和其他有意思的事。 ------------------------------------------------------------------------ 源代码下载 小鬼不牛,但和牛一样笨 很勤奋。如果有用错的地方小鬼还是很喜欢广泛听取建议的 。 不早了,睡了 先… 88
|