生成需要注意的。


1. DAL 层只有以下是需要 CodeSmith 动态生成的:TABLENAME、PRIMARYKEYCOLUMNNAME、SQL_INSERT、SQL_UPDATE


2. 在生成 DAL 层的 CodeSmith 生成代码中,什么一个变量

string dbParameter = "SqlParameter";  // 如果是 SQL Server ,否则为 MySqlParameter


3. 在 DAL 层什么一个变量

string dbHelperName = "MySqlHelper"; 如果是 SQL Server ,否则为 SQLDBHelper


4. 考虑用继承,提取一个 BaseDAL 类


5. DAL 层中的封装数据中 string 或 可空字段都要改为:  obj.Name = dr[i] == DBNull.Value ? null : Convert.ToString(dr[i]);

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


6.

原文地址:https://www.cnblogs.com/great/p/2428738.html