void IProviderExtend.CreateTable(MetaTable metaTable) { //var metaTable = services.Model.GetTable(metaTable); var command = MySqlBuilder.GetCreateTableCommand(metaTable); services.Context.ExecuteCommand(command); }
public void CreateDatabase() { if (DatabaseExists()) { throw SqlClient.Error.CreateDatabaseFailedBecauseSqlCEDatabaseAlreadyExists(dbName); } //创建数据库文件 var connection = new MySqlConnection(GetConnectionString(string.Empty)); connection.Open(); var transaction = connection.BeginTransaction(); Execute(connection, transaction, MySqlBuilder.GetCreateDatabaseCommand(dbName, null, null)); try { MetaModel model = services.Model; foreach (MetaTable table in model.GetTables()) { string createTableCommand = MySqlBuilder.GetCreateTableCommand(table); if (!string.IsNullOrEmpty(createTableCommand)) { Execute(connection, transaction, createTableCommand); } } foreach (MetaTable table in model.GetTables()) { foreach (string commandText in MySqlBuilder.GetCreateForeignKeyCommands(table)) { if (!string.IsNullOrEmpty(commandText)) { Execute(connection, transaction, commandText); } } } transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } }
public void CreateTable(MetaTable metaTable) { string createTableCommand = MySqlBuilder.GetCreateTableCommand(metaTable); Execute(Connection, Transaction, createTableCommand); }