EasyFastCMS系列教学课程——1、三层框架的搭建
在本系列教程中,我们以一个大型CMS系统的完整开发流程为例,和大家一起探讨net开发的经验和教训。在本程序中,我们采用了流行的三层/N层框架+仓储模式的架构模式。项目分层示意图:

- EasyFast.Web ——UI展示层,系统的操作界面。
- EasyFast.BLL ——业务逻辑层,用于处理程序中的业务逻辑。
- EasyFast.Model ——用于在各层之间传递数据。
- EasyFast.Utility ——公共类库
- EasyFast.Repository ——数据操作(数据仓储层)
- EasyFast.DBContext ——ORM工具层
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient; namespace EasyFast.Repository.Interface
{
public interface IRepository<T> where T : class
{
T GetById(int id);
T Find(string where, string orderColumn, List<SqlParameter> parameters); int Add(T model);
int Delete(int id);
int Update(T model); int GetPageCount(string tableName, string where, List<SqlParameter> parameters);
DataTable GetPageList(string tableName, string fieldNames, string where, string orderColumn, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters);
DataTable GetDataTable(string tableName, string fieldNames, string where, string orderColumn, List<SqlParameter> parameters);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EasyFast.Repository.Interface;
using System.Data;
using System.Data.SqlClient; namespace EasyFast.Repository
{
public class Repository<T> : IRepository<T> where T : class
{
public T GetById(int id)
{
T model = default(T);
return model;
}
public T Find(string where, string orderColumn, List<SqlParameter> parameters)
{
T model = default(T);
return model;
} public int Add(T model)
{
int _result = ;
return _result;
}
public int Delete(int id)
{
int _result = ;
return _result;
}
public int Update(T model)
{
int _result = ;
return _result;
} public int GetPageCount(string tableName, string where, List<SqlParameter> parameters)
{
int _result = ;
return _result;
}
public DataTable GetPageList(string tableName, string fieldNames, string where, string orderColumn, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters)
{
DataTable dt = new DataTable();
return dt;
}
public DataTable GetDataTable(string tableName, string fieldNames, string where, string orderColumn, List<SqlParameter> parameters)
{
DataTable dt = new DataTable();
return dt;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using EasyFast.Repository;
using EasyFast.Repository.Interface; namespace EasyFast.BLL
{
public class BaseBLL<T> where T : class
{ IRepository<T> repository = new Repository<T>();
protected readonly Object lockHelper = new object(); #region 获取model
public T GetById(int id)
{
return repository.GetById(id);
}
public T Find(string where)
{
return repository.Find(where,"", null);
}
public T Find(string where, List<SqlParameter> parameters)
{
return repository.Find(where,"", parameters);
} public T Find(string where, string orderColumn, List<SqlParameter> parameters)
{
return repository.Find(where, orderColumn, parameters);
}
#endregion #region 新增一条记录
public int Add(T model)
{
return repository.Add(model);
}
#endregion #region 删除一条记录
public int Delete(int id)
{
return repository.Delete(id);
}
#endregion #region 更新一条记录 public int Update(T model)
{
return repository.Update(model);
}
#endregion #region 获取指定条件的记录集
public virtual DataTable GetDataTable(string tableName, string fieldNames, string where, string orderColumn, List<SqlParameter> parameters)
{
return repository.GetDataTable(tableName, fieldNames, where, orderColumn, parameters);
} public virtual DataTable GetDataTable(string fieldNames, string where, string orderColumn, List<SqlParameter> parameters)
{
return repository.GetDataTable("", fieldNames, where, orderColumn, parameters);
} public virtual DataTable GetDataTable(string fieldNames, string where, List<SqlParameter> parameters)
{
return repository.GetDataTable("", fieldNames, where, "", parameters);
} public virtual DataTable GetDataTable(string where, List<SqlParameter> parameters)
{
return repository.GetDataTable("", "*", where, "", parameters);
} public virtual DataTable GetDataTable(string where)
{
return repository.GetDataTable("", "*", where, "", null);
} public virtual DataTable GetDataTable()
{
return repository.GetDataTable("", "*", "", "", null);
}
#endregion #region 获取指定条件的记录数
public virtual int GetPageCount(string tableName, string where, List<SqlParameter> parameters)
{
return repository.GetPageCount(tableName, where, parameters);
} public virtual int GetPageCount(string where, List<SqlParameter> parameters)
{
return repository.GetPageCount("", where, parameters);
} public virtual int GetPageCount(string where)
{
return repository.GetPageCount("", where, null);
} public virtual int GetPageCount()
{
return repository.GetPageCount("", "", null);
}
#endregion #region 分页获取指定条件的记录
public virtual DataTable GetPageList(string tableName, string fieldNames, string where, string orderColumn, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters)
{
return repository.GetPageList(tableName, fieldNames, where, orderColumn, startRecordIndex, endRecordIndex, parameters);
} public virtual DataTable GetPageList(string tableName, string fieldNames, string where, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters)
{
return repository.GetPageList(tableName, fieldNames, where, "", startRecordIndex, endRecordIndex, parameters);
} public virtual DataTable GetPageList(string fieldNames, string where, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters)
{
return repository.GetPageList("", fieldNames, where, "", startRecordIndex, endRecordIndex, parameters);
} public virtual DataTable GetPageList(string where, int startRecordIndex, int endRecordIndex, List<SqlParameter> parameters)
{
return repository.GetPageList("", "*", where, "", startRecordIndex, endRecordIndex, parameters);
} public virtual DataTable GetPageList(string where, int startRecordIndex, int endRecordIndex)
{
return repository.GetPageList("", "*", where, "", startRecordIndex, endRecordIndex, null);
} public virtual DataTable GetPageList(int startRecordIndex, int endRecordIndex)
{
return repository.GetPageList("", "*", "", "", startRecordIndex, endRecordIndex, null);
}
#endregion
}
}
示例代码下载: EasyFastCMS-2014.05.28.zip
EasyFastCMS系列教学课程——1、三层框架的搭建的更多相关文章
- EasyFastCMS系列教学课程——2、底层代码 ModelHelper与SQLHelper简介
从本节课开始,我们开始逐步正式进入实际的编码过程中.本节课的核心内容为SQLHeelper和ModelHelper两个核心类库的介绍. SQLHelper这个类相信大家都很熟悉了,他是微软petsho ...
- .Net Core2.2 + EF Core + DI,三层框架项目搭建教程
笔记: 近两年.Net Core发展的很快,目前最新版为3.0预览版,之前在网上买了一本1.1版书籍都还没来得及看呢,估计现在拿出来看也毫无意义了.已多年.net工作经验,看书不如直接实际上手来得快, ...
- 系列免费课程汇总(Java、单体应用、微服务、物联网、SaaS)
概述 2020年春节尽在眼前,又忙碌了一年的你一定有很多收获:是升职加薪,还是收获爱情?是买房置业,还是新添人口? 我在2019年的最大收获是:我的第二枚千金诞生,使我顺利加入富豪行列! 新年伊始我们 ...
- 微软云平台windows azure入门系列八课程
微软云平台windows azure入门系列八课程: Windows Azure入门教学系列 (一): 创建第一个WebRole程序与部署 Windows Azure入门教学系列 (二): 创建第一个 ...
- 【.NET特供-第三季】ASP.NET MVC系列:MVC与三层图形对照
近期在开发小组在研究:BS项目中是利用'MVC框架'还是继续沿用'三层'的问题. 由于曾经的.NET项目大多数都是利用三层开发的,所以大多数人都可以对三层进行熟练地运用.而项目的開始我们也曾听说过MV ...
- [No000019A]【波浪理论精典教学课程】
波浪理论的产生和发展 拉尔夫·纳尔逊·艾略特(Ralph Nelson Elliott ),是波浪理论的创始人.1871年7月28日出生在美国密苏里州堪萨斯市的玛丽斯维利镇Marysville ...
- RobotFrameWork系列免费课程-开课了~
1. 背景介绍 有一段时间没有发表过文章了,一方面除了自己确实变得懒惰外,另一方面也确实有其它事情,无法抽出闲余时间来坚持写下去. 之前在博客园中,发表了关于<公开课一:Robot FrameW ...
- Java多线程系列--“JUC锁”01之 框架
本章,我们介绍锁的架构:后面的章节将会对它们逐个进行分析介绍.目录如下:01. Java多线程系列--“JUC锁”01之 框架02. Java多线程系列--“JUC锁”02之 互斥锁Reentrant ...
- 学习笔记_Java_day12_设计模式MVC(13).JavaWeb的三层框架(14)
MVC 1. 什么是MVC MVC模式(Model-View-Controller)是软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型(Model).视图(View)和控制器(Contr ...
随机推荐
- mysql 随机查询 记录集
有时候需求需要随机从数据库查询若干条记录集,网上搜了一下,几篇博文都是些重复的.....不知道他们谁抄的谁的,这里除了介绍提供一种笔者自己想到的方法,本质都是利用mysql 的rand() 第一种方法 ...
- UNITY UI字体模糊的原因
根本原因:像素少. 解决办法:字体的 font size将像素设置大些,然后用scale来缩放大小
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 18—Photo OCR 应用实例:图片文字识别
Lecture 18—Photo OCR 应用实例:图片文字识别 18.1 问题描述和流程图 Problem Description and Pipeline 图像文字识别需要如下步骤: 1.文字侦测 ...
- Mysql事务及行级锁
事务隔离级别 数据库事务隔离级别,只是针对一个事务能不能读取其它事务的中间结果. Read Uncommitted (读取未提交内容) 在该隔离级别,所有事务都可以看到其他未提交事务的执行结果.本隔离 ...
- UV mapping
[UV mapping] UV mapping is the 3D modeling process of making a 2D image representation of a 3D model ...
- GC类
[GC类] GC是一个静态类. 垃圾回收器跟踪并回收托管内存中分配的对象.垃圾回收器定期执行垃圾回收以回收分配给没有有效引用的对象的内存.当使用可用内存不能满足内存请求时,垃圾回收会自动进行.或者,应 ...
- 少一些套路,多一些真诚 ——groovy消灭表现层套路
初次认识groovy是在2009年,当时看了Manning出版的<Groovy in Action 1st Edition>,对groovy这个语言的交互性shell,以及灵活的语法留 ...
- Opencv 分水岭分割图片
#include <iostream>#include <opencv2/opencv.hpp> using namespace std;using namespace cv; ...
- jvisualvm远程监控服务器tomcat
1.在 {服务器tomcat路径}/bin/catalina.sh 中,的[# OS specific support. $var _must_ be set to either true or f ...
- SVM之SMO算法(转)
支持向量机(Support Vector Machine)-----SVM之SMO算法(转) 此文转自两篇博文 有修改 序列最小优化算法(英语:Sequential minimal optimizat ...