コード例 #1
0
        private static string ToNewClass2(DBTableInfo ti)
        {
            StringBuilder cBuilder = new StringBuilder();

            cBuilder.AppendLine("--【类赋值2】------------------------------------------");
            cBuilder.AppendLine("var newObj = new " + ti.TableName + " ();");
            foreach (DBColInfo c in ti.Cols)
            {
                var propType = TypeMap.GetCShartType(c.ColumnType);
                if (string.IsNullOrWhiteSpace(c.ColumnName) == false)
                {
                    cBuilder.AppendLine("newObj." + c.ColumnName + " = " + TypeMap.GetCSharpDefaultVal(propType) + ";");
                }
            }
            cBuilder.AppendLine("");
            return(cBuilder.ToString());
        }