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  
{  
    /// <summary>  
    /// <%=ClearPrefix(ViewName.Name) %> Interface  
    /// </summary>  
    public interface I<%=ClearPrefix(ViewName.Name) %>  
    {  
        #region  成员方法
        /// <summary>
		/// 得到最大ID
		/// </summary>
		int GetMaxId(string colName);
        
		/// <summary>
		/// 是否存在该记录
		/// </summary>
	    bool Exists();
        
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		//m<%=ClearPrefix(ViewName.Name) %> GetModel();
		//m<%=ClearPrefix(ViewName.Name) %> DataRowToModel(DataRow row);
        
		/// <summary>
		/// 获得数据列表
		/// </summary>
		DataSet GetList(string strWhere);
        
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		DataSet GetList(int Top,string strWhere,string filedOrder);
		int GetRecordCount(string strWhere);
		DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex);
        
		/// <summary>
		/// 根据分页获得数据列表
		/// </summary>
		//DataSet GetList(int PageSize,int PageIndex,string strWhere);
        
		#endregion  成员方法

		#region  MethodEx

		#endregion  MethodEx
		
    }  
}  
<script runat="template">  
public string ClearPrefix(string name)  
{  
    //int mIndex=name.IndexOf(TablePrefix);  
    //string strResult=name.Remove(0,TablePrefix.Length);  
    return name;
}
</script>

 


Comments are closed.