ASP.NET三层架构源码(CodeSmith版)之九:View-IDAL层(数据访问抽象层)
动软代码生成器生成的ASP.NET三层架构代码比较规范,是学习ASP.NET的好例子
此三层架构改造自动软的工厂模式模板,使用CodeSmith进行重写,以方便大家修改模板文件
以下是针对视图IDAL层的源码:
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Text" %>
<%@ Property Name="Namespace" Type="String" Category="Context" Description="NameSpace"%>
<%@ Property Name="Author" Type="String" Category="Context" Description="Author" Default="chenr"%>
<%@ Property Name="ViewName" Type="ViewSchema" DeepLoad="True" Optional="False" Category="01. Getting Started - Required" Description="" %>
/*------------------------------------------------
// File Name:I<%=ClearPrefix(ViewName.Name) %>.cs
// File Description:<%=ClearPrefix(ViewName.Name) %> Interface
// Author:<%=Author%>
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%>
//------------------------------------------------*/
using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using <%=Namespace%>.Model;
namespace <%=Namespace%>.IDAL
{
///
/// <%=ClearPrefix(ViewName.Name) %> Interface
///
public interface I<%=ClearPrefix(ViewName.Name) %>
{
#region 成员方法
///
/// 得到最大ID
///
int GetMaxId(string colName);
///
/// 是否存在该记录
///
bool Exists();
///
/// 得到一个对象实体
///
//m<%=ClearPrefix(ViewName.Name) %> GetModel();
//m<%=ClearPrefix(ViewName.Name) %> DataRowToModel(DataRow row);
///
/// 获得数据列表
///
DataSet GetList(string strWhere);
///
/// 获得前几行数据
///
DataSet GetList(int Top,string strWhere,string filedOrder);
int GetRecordCount(string strWhere);
DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex);
///
/// 根据分页获得数据列表
///
//DataSet GetList(int PageSize,int PageIndex,string strWhere);
#endregion 成员方法
#region MethodEx
#endregion MethodEx
}
}