///////////////////////以上生成 Model ////////////////////////////以下生成 数据访问层 #region 生成单表数据访问层 /// <summary> /// 生成单表数据访问层 /// </summary> /// <param name="confirmWrite">是否生成文件</param> /// <returns></returns> public string ToDataAccess(bool confirmWrite, List <string> tablesName) { StringBuilder ret = new StringBuilder(); ProcTable pt = new ProcTable(); ProcString ps = new ProcString(); ps.SetTabs(strNameSpace); ps.strImportNameSpace = @"using System; using System.Data; using System.Collections.Generic; "; foreach (string tableName in tablesName) { string strMember = @"IDBOperator idb = DBOperator.GetInstance();"; string strClassBody = ps.GetDataAccessClassBody(tableName, strPrefix, strNameSpace); string str = ps.GetCLassByModel(strNameSpace, strPrefix, tableName, strADO, strMember, strClassBody); ret.Append(str); #region 写文件 if (confirmWrite) { string tem = path + "/ADO/"; string strClassName = ps.GetClassNameByTableName(tableName, strPrefix); if (!Directory.Exists(tem)) { Directory.CreateDirectory(tem); } string fullpath = tem + strADO + strClassName + ".cs"; Write(fullpath, ret.ToString()); } #endregion } return(ret.ToString()); }