Пример #1
0
        public static void SQLTableToCSharp()
        {
            //读取文件信息
            var folder = FileHelper.GetDictionary(Application.dataPath + "/" + ProjectPathConfig.DataBasePath);
            var db     = folder.GetFiles("*.db");

            for (int i = 0; i < db.Length; i++)
            {
                string         dbName   = PathHelper.FileNameWithoutSuffix(db[i].Name);
                SqliteDatabase database = SQLMgr.S.Open(dbName);
                //获取该数据库下面的所有表
                var reader = database.GetAllTableName();
                while (reader.Read())
                {
                    //获取表信息
                    string tableName   = (string)reader[0];
                    var    tableReader = database.GetTableInfo(tableName);

                    string dirName = Application.dataPath + "/" + ProjectPathConfig.tableCsharpPath + "Sql/Genetate/" + dbName + "/" + tableName + "/";
                    GenerateDataFile(tableName, tableReader, dirName);
                    GenerateDataTableFile(dbName, tableName, tableReader, dirName);
                    string dirExtendName = Application.dataPath + "/" + ProjectPathConfig.tableCsharpPath + "Sql/Extend/" + dbName + "/" + tableName + "/";
                    GenerateDataExtendFile(tableName, dirExtendName);
                    GenerateDataTableExtendFile(tableName, dirExtendName);
                }
            }

            AssetDatabase.Refresh();
        }