Exemple #1
0
        /// <summary>
        /// 生成访问层类的主体
        /// </summary>
        /// <param name="strTableName">表名</param>
        /// <param name="strPrefix">表名前缀(要处理的)</param>
        /// <param name="strNamespace">名称空间</param>
        /// <returns></returns>
        public string GetDataAccessClassBody_SQL(string strTableName
                                                 , string strPrefix
                                                 , string strNamespace)
        {
            StringBuilder ret = new StringBuilder();

            ProcString ps = new ProcString();

            ps.SetTabs(strNamespace);
            TableInfo tableInfo = new TableInfo(strNamespace, strPrefix, strTableName);

            StringBuilder sbBody = new StringBuilder();

            sbBody.AppendLine(ps.tabMember + "#region SetSQL Function");
            #region public ind SetInsert()

            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "/// 获取添加数据的SQL语句");
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.Append(ps.tabMember + "public  string SetInsert()");

            sbBody.AppendLine(ps.tabMember + "{");
            sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"INSERT INTO [" + strTableName + "] (" + tableInfo.GetInsertFields("") + ") VALUES (" + tableInfo.GetInsertValues_sp() + ")\";");
            if (strTableName != "Area")
            {
                sbBody.AppendLine(ps.tabLocalVar + tableInfo.GetKeyValue() + "= snowflakeIdWorker.NextId().ToString();");
            }
            sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.AllColumns));
            sbBody.AppendLine(ps.tabLocalVar + "new DbHelper().ExcuteNonQuery(strSQL,sp);");
            sbBody.AppendLine(ps.tabLocalVar + "return " + tableInfo.GetKeyValue() + ";");
            sbBody.AppendLine(ps.tabMember + "}");
            //事务处理
            sbBody.Append(ps.tabMember + "public  string SetInsertForTransaction(DbHelper dbHelper)");
            sbBody.AppendLine(ps.tabMember + "{");
            sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"INSERT INTO [" + strTableName + "] (" + tableInfo.GetInsertFields("") + ") VALUES (" + tableInfo.GetInsertValues_sp() + ")\";");
            sbBody.AppendLine(ps.tabLocalVar + tableInfo.GetKeyValue() + "= snowflakeIdWorker.NextId().ToString();");
            sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.AllColumns));
            sbBody.AppendLine(ps.tabLocalVar + "dbHelper.ExcuteNonQueryForTransaction(strSQL,sp);");
            sbBody.AppendLine(ps.tabLocalVar + "return " + tableInfo.GetKeyValue() + ";");
            sbBody.AppendLine(ps.tabMember + "}");
            #endregion
            #region public ind Update()
            //-----------
            if (tableInfo.KeyColumns.Length != tableInfo.AllColumns.Length)//关系表没有数据需要更新,只有主外键。如需更新,删除重新添加。
            {
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "/// 更新数据");
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "public int SetUpdateForAll()");
                sbBody.AppendLine(ps.tabMember + "{");
                //20210317--lsj--作废,使用Parameter
                //sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET " + tableInfo.GetUpdateValues(""));

                sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET " + tableInfo.GetUpdateValues_Parameter());
                sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.AllColumns));
                sbBody.AppendLine(ps.tabLocalVar + "return new DbHelper().ExcuteNonQuery(strSQL,sp);");
                sbBody.AppendLine(ps.tabMember + "}");
                //-----------
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "/// 更新部分数据");
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "public int SetUpdate()");
                sbBody.AppendLine(ps.tabMember + "{");
                //20210317--lsj--作废,使用Parameter
                //sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET " + tableInfo.GetUpdateValues(""));
                sbBody.AppendLine(ps.tabLocalVar + "bool boolPartial = false;");
                sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET \";");
                sbBody.AppendLine(tableInfo.GetUpdateValues_ParameterForPartial());
                sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.AllColumns));
                sbBody.AppendLine(ps.tabLocalVar + "return new DbHelper().ExcuteNonQuery(strSQL,sp);");
                sbBody.AppendLine(ps.tabMember + "}");
                //事务处理
                sbBody.AppendLine(ps.tabMember + "public int SetUpdateForTransaction(DbHelper dbHelper)");
                sbBody.AppendLine(ps.tabMember + "{");
                //20210317--lsj--作废,使用Parameter
                //sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET " + tableInfo.GetUpdateValues(""));
                sbBody.AppendLine(ps.tabLocalVar + "bool boolPartial = false;");
                sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"UPDATE [" + strTableName + "] SET \";");
                sbBody.AppendLine(tableInfo.GetUpdateValues_ParameterForPartial());
                sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.AllColumns));
                sbBody.AppendLine(ps.tabLocalVar + "return dbHelper.ExcuteNonQueryForTransaction(strSQL,sp);");
                sbBody.AppendLine(ps.tabMember + "}");
                //-----------
                #region public ind Delete()
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "/// 获取删除数据的SQL语句");
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "public int SetDelete(string " + tableInfo.GetKeyValue() + ")");
                sbBody.AppendLine(ps.tabMember + "{");
                if (tableInfo.ExistIsDeleted())
                {
                    if (tableInfo.ExistChangeTime())
                    {
                        sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"update [" + strTableName + "] set IsDeleted=1, ChangeTime=getdate() WHERE " + tableInfo.GetDeleteValues_sp());
                    }
                    else
                    {
                        sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"update [" + strTableName + "] set IsDeleted=1 WHERE " + tableInfo.GetDeleteValues_sp());
                    }
                }
                else
                {
                    sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"DELETE [" + strTableName + "] WHERE " + tableInfo.GetDeleteValues_sp());
                }
                sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.KeyColumns));
                sbBody.AppendLine(ps.tabLocalVar + "return new DbHelper().ExcuteNonQuery(strSQL,sp);");
                sbBody.AppendLine(ps.tabMember + "}");


                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "/// 获取删除数据的SQL语句");
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "public int SetDelete()");
                sbBody.AppendLine(ps.tabMember + "{");
                if (tableInfo.ExistIsDeleted())
                {
                    if (tableInfo.ExistChangeTime())
                    {
                        sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"update [" + strTableName + "] set IsDeleted=1, ChangeTime=getdate() WHERE " + tableInfo.GetDeleteValues_sp());
                    }
                    else
                    {
                        sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"update [" + strTableName + "] set IsDeleted=1 WHERE " + tableInfo.GetDeleteValues_sp());
                    }
                }
                else
                {
                    sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \"DELETE [" + strTableName + "] WHERE " + tableInfo.GetDeleteValues_sp());
                }
                sbBody.AppendLine(tableInfo.GetSqlParameter(ColumnsType.KeyColumns));
                sbBody.AppendLine(ps.tabLocalVar + "return new DbHelper().ExcuteNonQuery(strSQL,sp);");
                sbBody.AppendLine(ps.tabMember + "}");
                #endregion
                //lsj--类名
                //string strClassName = strTableName;//ps.GetClassName(strTableName);//lsj
                string strClassName = ps.GetClassName(strTableName);//2021-2-2-lsj-类名首字母大写
                //lsj--小写的类名--在此做类的对象来用。
                string strLowerClassName = ps.ConvertStringToUpperOrLower(strClassName, false);
                //------------------------------
            }
            #endregion

            sbBody.AppendLine(ps.tabMember + "#endregion SetSQL Function");
            ret.Append(sbBody.ToString());
            return(ret.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 生成数据库访问的函数
        /// </summary>
        /// <param name="strTableName"></param>
        /// <param name="strPrefix"></param>
        /// <param name="strNamespace"></param>
        /// <returns></returns>
        public string GetDataAccessEntity(string strTableName
                                          , string strPrefix
                                          , string strNamespace)
        {
            StringBuilder ret = new StringBuilder();

            ProcString ps = new ProcString();

            ps.SetTabs(strNamespace);
            TableInfo tableInfo = new TableInfo(strNamespace, strPrefix, strTableName);

            StringBuilder sbBody = new StringBuilder();

            string strClassName   = ps.GetClassName(strTableName); //2021-2-2-lsj-类名首字母大写
            string strClassObject = strClassName.ToLower();        //2021-2-2-lsj-类对象全部字母小写

            sbBody.AppendLine(ps.tabMember + "#region GetObject Function");
            #region public GetUserList
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "/// 获取" + strClassName + "数据");
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "public List<" + strClassName + "> Get" + strClassName + "List(int Page, int Size)");
            sbBody.AppendLine(ps.tabMember + "{");
            sbBody.AppendLine(ps.tabLocalVar + "List<" + strClassName + "> " + strClassObject + "s = new List<" + strClassName + ">();");
            sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \" select * from \"");
            sbBody.AppendLine(ps.tabLocalVar + "+ \" (select *,row_number() over (order by [" + strTableName + "]." + tableInfo.KeyColumns[0] + ") as t \"");
            sbBody.Append(ps.tabLocalVar + "+ \" from [" + strTableName + "] ");
            if (tableInfo.ExistIsDeleted())
            {
                sbBody.Append(" where IsDeleted=0 ");
            }
            sbBody.AppendLine(" ) as o where o.t between @Begin and @End\"; ");
            sbBody.AppendLine(ps.tabLocalVar + "SqlParameter[] sp = new SqlParameter[2];");
            sbBody.AppendLine(ps.tabLocalVar + "sp[0] = new SqlParameter(\"@Begin\", (Page - 1) * Size + 1);");
            sbBody.AppendLine(ps.tabLocalVar + "sp[1] = new SqlParameter(\"@End\", Page * Size);");
            sbBody.AppendLine(ps.tabLocalVar + "using (SqlDataReader dr = new DbHelper().ExcuteReader(strSQL, sp)){");
            sbBody.AppendLine(ps.tabLocalVar + "    while (dr.Read()){");
            sbBody.AppendLine(ps.tabLocalVar + "    " + strClassName + " " + strClassObject + " = new  " + strClassName + "();");
            sbBody.AppendLine(tableInfo.GetEntity(strClassName));

            sbBody.AppendLine(ps.tabLocalVar + "    " + strClassObject + "s.Add(" + strClassObject + ");}}");
            sbBody.AppendLine(ps.tabLocalVar + "return " + strClassObject + "s;");
            sbBody.AppendLine(ps.tabMember + "}");

            #endregion
            #region public GetUsersCount
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "/// 获取" + strClassName + "总数");
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "public int Get" + strClassName + "sCount()");
            sbBody.AppendLine(ps.tabMember + "{");
            sbBody.Append(ps.tabLocalVar + "string strSQL = \" select count(*) from  [" + strTableName + "] ");
            if (tableInfo.ExistIsDeleted())
            {
                sbBody.Append(" where IsDeleted=0 ");
            }
            sbBody.AppendLine(" \"; ");
            sbBody.AppendLine(ps.tabLocalVar + "using (SqlDataReader dr = new DbHelper().ExcuteReader(strSQL)){");
            sbBody.AppendLine(ps.tabLocalVar + "     if (dr.Read()){");
            sbBody.AppendLine(ps.tabLocalVar + "     return dr[0] == DBNull.Value ? 0 : Convert.ToInt32(dr[0].ToString());}");
            sbBody.AppendLine(ps.tabLocalVar + "     else return -1;}");
            sbBody.AppendLine(ps.tabMember + "}");

            #endregion
            #region public GetUserList
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "/// 获取" + strClassName + "数据");
            sbBody.AppendLine(ps.tabMember + "/// <summary>");
            sbBody.AppendLine(ps.tabMember + "public List<" + strClassName + "> Get" + strClassName + "List()");
            sbBody.AppendLine(ps.tabMember + "{");
            sbBody.AppendLine(ps.tabLocalVar + "List<" + strClassName + "> " + strClassObject + "s = new List<" + strClassName + ">();");
            sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \" select * from [" + strTableName + "]\";");
            sbBody.AppendLine(ps.tabLocalVar + "using (SqlDataReader dr = new DbHelper().ExcuteReader(strSQL)){");
            sbBody.AppendLine(ps.tabLocalVar + "    while (dr.Read()){");
            sbBody.AppendLine(ps.tabLocalVar + "    " + strClassName + " " + strClassObject + " = new  " + strClassName + "();");
            sbBody.AppendLine(tableInfo.GetEntity(strClassName));

            sbBody.AppendLine(ps.tabLocalVar + "    " + strClassObject + "s.Add(" + strClassObject + ");}}");
            sbBody.AppendLine(ps.tabLocalVar + "return " + strClassObject + "s;");
            sbBody.AppendLine(ps.tabMember + "}");

            if (tableInfo.ExistIsDeleted())
            {
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "/// 获取" + strClassName + "数据 ");
                sbBody.AppendLine(ps.tabMember + "/// <summary>");
                sbBody.AppendLine(ps.tabMember + "public List<" + strClassName + "> Get" + strClassName + "ListNotDeleted()");
                sbBody.AppendLine(ps.tabMember + "{");
                sbBody.AppendLine(ps.tabLocalVar + "List<" + strClassName + "> " + strClassObject + "s = new List<" + strClassName + ">();");
                sbBody.AppendLine(ps.tabLocalVar + "string strSQL = \" select * from [" + strTableName + "] Where IsDeleted=0\";");
                sbBody.AppendLine(ps.tabLocalVar + "using (SqlDataReader dr = new DbHelper().ExcuteReader(strSQL)){");
                sbBody.AppendLine(ps.tabLocalVar + "    while (dr.Read()){");
                sbBody.AppendLine(ps.tabLocalVar + "    " + strClassName + " " + strClassObject + " = new  " + strClassName + "();");
                sbBody.AppendLine(tableInfo.GetEntity(strClassName));

                sbBody.AppendLine(ps.tabLocalVar + "    " + strClassObject + "s.Add(" + strClassObject + ");}}");
                sbBody.AppendLine(ps.tabLocalVar + "return " + strClassObject + "s;");
                sbBody.AppendLine(ps.tabMember + "}");
            }
            #endregion

            sbBody.AppendLine(ps.tabMember + "#endregion GetObject Function");
            ret.Append(sbBody.ToString());
            return(ret.ToString());
        }
Exemple #3
0
        /// <summary>
        /// 多表时,生成单表实体字符串
        /// </summary>
        /// <param name="dsColumnType">列类型表</param>
        /// <param name="dtColumnDescription">列描述表</param>
        /// <param name="dtDescription">表描述(表)</param>
        /// <returns></returns>
        public string GetTable(DataTable dtColumnType
                               , DataTable dtColumnDescription
                               , string strTableDescription
                               , string strPrefix
                               , string strNamespace)
        {
            StringBuilder ret          = new StringBuilder();
            string        strTableName = dtColumnType.TableName;


            //lsj--构造方法1所用的参数默认值
            string strDefaultValue = "";
            //lsj--构造方法2所用的参数列表
            string strPara = "";
            //lsj--构造方法3的赋值
            int    index    = 0;
            string strIndex = "";
            string strValue = "";

            //lsj--构造方法1所用的赋值语句。
            string[] strSetValues1 = new string[dtColumnType.Rows.Count];
            //lsj--构造方法2所用的赋值语句。
            string[] strSetValues2 = new string[dtColumnType.Rows.Count];

            ProcString ps = new ProcString();

            ps.SetTabs(strNamespace);
            //lsj--类名
            string strClassName = ps.GetClassName(strTableName);//2021-2-2-lsj

            //lsj--小写的类名--在此做类的对象来用。
            string strLowerClassName = ps.ConvertStringToUpperOrLower(strClassName, false);

            TableInfo tableInfo = new TableInfo(strNamespace, strPrefix, strTableName);

            if (string.IsNullOrEmpty(tableInfo.strPKName))
            {
                return("");
            }

            //---------------------------------------------
            #region  Member Variables / Attributes  属性
            StringBuilder sbBody = new StringBuilder();

            sbBody.AppendLine(ps.tabMember + "#region Member Variables");
            sbBody.AppendLine(ps.tabMember + "SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker();//雪花ID");
            for (int i = 0; i < dtColumnType.Rows.Count; i++)
            {
                DataRow drType     = dtColumnType.Rows[i];
                string  columnName = drType["Column_name"].ToString(); //列名
                string  columnType = drType["Type"].ToString();        //列数据类型
                //string columnDefault = drType["Data_default"].ToString().Trim();//列默认值//增加默认值 lsj@20130222--不支持SYSTIMESTAMP等系统函数
                //2021-2-2-lsj--未找到默认值
                string columnDefault        = "";
                string firstLowerColumnName = "";//首字母小写,用于字段

                #region 以下为字段
                firstLowerColumnName = ps.ConvertStringToUpperOrLower(columnName, false);
                //if (tableInfo.KeyColumns.Length>1 && tableInfo.KeyColumns[0] == columnName && tableInfo.KeyType == "NUMBER")
                //    sbBody.AppendLine(ps.tabMember + "private Int64 " + firstLowerColumnName + ";");
                //else
                //{
                // sbBody.AppendLine(ps.tabMember + "private " + ps.ConvertType(columnType, columnName, tableInfo) + " " + firstLowerColumnName + ";");
                //}
                //列默认值//增加默认值 lsj@20130222--不支持SYSTIMESTAMP等系统函数

                sbBody.AppendLine(ps.tabMember + "private " + ps.ConvertType(columnType, columnName, tableInfo) + " " + firstLowerColumnName + ";");

                #endregion
            }
            sbBody.AppendLine(ps.tabMember + "#endregion");
            sbBody.AppendLine(ps.tabMember + "#region Attributes");
            for (int n = 0; n < dtColumnType.Rows.Count; n++)
            {
                DataRow drType     = dtColumnType.Rows[n];
                string  columnName = drType["Column_name"].ToString(); //列名
                string  columnType = drType["Type"].ToString();        //列数据类型
                //string columnDefault = drType["Data_default"].ToString().Trim();//列默认值//增加默认值 lsj@20130222--不支持SYSTIMESTAMP等系统函数
                //2021-2-2-lsj--未找到默认值
                string columnDefault        = "";
                string firstLowerColumnName = ""; //首字母小写,用于字段
                string firstUpperColumnName = ""; //首字母大写,用于属性
                string strColumnDescription = ""; //列描述
                firstLowerColumnName = ps.ConvertStringToUpperOrLower(columnName, false);
                firstUpperColumnName = ps.ConvertStringToUpperOrLower(columnName, true);
                if (null != dtColumnDescription)
                {
                    for (int i = 0; i < dtColumnDescription.Rows.Count; i++)
                    {
                        string strColumnName = dtColumnDescription.Rows[i]["ColumnName"].ToString();

                        if (strColumnName == columnName)
                        {
                            strColumnDescription = dtColumnDescription.Rows[i]["ColumnDescription"].ToString();

                            dtColumnDescription.Rows.RemoveAt(i);
                            break;
                        }
                    }
                }

                #region 以下为属性
                if (!string.IsNullOrEmpty(strColumnDescription))
                {
                    sbBody.AppendLine(ps.tabMember + "/// <summary>");
                    sbBody.AppendLine(ps.tabMember + "/// " + strColumnDescription);
                    sbBody.AppendLine(ps.tabMember + "/// <summary>");
                }
                //sbBody.AppendLine(ps.tabMember + "[DataMember]");//lsj-2021-2-2
                firstUpperColumnName = ps.ConvertStringToUpperOrLower(columnName, true);
                firstUpperColumnName = ps.ConvertToSpecial(firstUpperColumnName, strTableName);

                //if (n == 0 && tableInfo.KeyColumns[0] == columnName && tableInfo.KeyType == "NUMBER")
                //    sbBody.AppendLine(ps.tabMember + "public Int64 " + firstUpperColumnName);
                //else
                //{
                sbBody.AppendLine(ps.tabMember + "public " + ps.ConvertType(columnType, columnName, tableInfo) + " " + firstUpperColumnName);
                //}
                sbBody.AppendLine(ps.tabMember + "{");
                sbBody.AppendLine(ps.tabLocalVar + "get{ return " + firstLowerColumnName + "; }");
                sbBody.Append(ps.tabLocalVar + "set{ " + firstLowerColumnName + " = value; ");
                sbBody.AppendLine("}");
                sbBody.AppendLine(ps.tabMember + "}");
                //----------------------------------------------
                strSetValues1[index] = ps.tabLocalVar + "this." + firstLowerColumnName + " = " + firstLowerColumnName + ";//" + strColumnDescription;
                strSetValues2[index] = ps.tabLocalVar + "this." + firstLowerColumnName + " = " + strLowerClassName + "." + firstLowerColumnName + ";//" + strColumnDescription;
                if (index == 0)
                {
                    //lsj--构造方法1所用的参数默认值
                    //增加默认值 lsj@20130222--不支持SYSTIMESTAMP等系统函数
                    strDefaultValue += ps.ConvertDefaultValue(columnType, columnName, columnDefault);
                    //lsj--构造方法2所用的参数列表
                    //if (n == 0 && tableInfo.KeyColumns[0] == columnName && tableInfo.KeyType == "NUMBER")
                    //    strPara += " Int64 " + firstLowerColumnName;
                    //else
                    strPara += ps.ConvertType(columnType, columnName, tableInfo) + " " + firstLowerColumnName;
                    //lsj--构造方法3的赋值
                    strIndex += "{" + index.ToString() + "}";
                    strValue += "this." + firstLowerColumnName;
                }
                else//前面加,
                {
                    //lsj--构造方法1所用的参数默认值
                    if (columnName == "")
                    {
                        strDefaultValue += ",0";
                    }
                    else
                    {
                        strDefaultValue += "," + ps.ConvertDefaultValue(columnType, columnName, columnDefault);
                    }
                    //lsj--构造方法2所用的参数列表
                    strPara += "," + ps.ConvertType(columnType, columnName, tableInfo) + " " + firstLowerColumnName;
                    //lsj--构造方法3的赋值
                    strIndex += "," + "{" + index.ToString() + "}";
                    strValue += ",this." + firstLowerColumnName;
                }

                //\"{0},{1},{2},{3}\", this.id, this.code, this.name, this.frequency
                index++;
                #endregion
            }
            sbBody.AppendLine(ps.tabMember + "#endregion ");
            #endregion

            #region Constructors--构造方法//lsj
            sbBody.AppendLine(ps.tabMember + "#region Constructors");
            //构造方法1
            sbBody.AppendLine(ps.tabMember + "public " + strClassName + " (): this(" + strDefaultValue + "){}");
            //构造方法2
            sbBody.AppendLine(ps.tabMember + "public " + strClassName + " (" + strPara + ")");
            sbBody.AppendLine(ps.tabMember + "{");
            foreach (string setValue in strSetValues1)
            {
                sbBody.AppendLine(setValue);
            }
            sbBody.AppendLine(ps.tabMember + "}");
            //构造方法3

            sbBody.AppendLine(ps.tabMember + "public " + strClassName + " (" + strClassName + " " + strLowerClassName + ")");
            sbBody.AppendLine(ps.tabMember + "{");
            foreach (string setValue in strSetValues2)
            {
                sbBody.AppendLine(setValue);
            }
            sbBody.AppendLine(ps.tabMember + "}");

            sbBody.AppendLine(ps.tabMember + "#endregion ");
            #endregion



            sbBody.Append(ps.GetDataAccessClassBody_SQL(strTableName, strPrefix, strNamespace));
            //2021-2-10-lsj-写入数据库
            sbBody.Append(ps.GetDataAccessEntity(strTableName, strPrefix, strNamespace));

            string strClass = ps.GetCLassByModel(strNamespace, strPrefix, strTableName, sbBody.ToString());

            ret.Append(strClass);

            return(ret.ToString());
        }