internal void Flush()
        {
            _currentAddFieldStatment = null;
            _currentTableInfo = null;
            _currentTableStatment = null;

            string commandText = string.Join(";", _tableStatments.Select(x => ParseStatement(x)).Where(x => !string.IsNullOrWhiteSpace(x)));

            if (string.IsNullOrWhiteSpace(commandText))
                return;

            using (DbCommand command = _getCommandFunc())
            {
                DbConnection connection = _databaseProvider.GetConnection(_connectionString);
                try
                {
                    if (connection.State != System.Data.ConnectionState.Open)
                        connection.Open();

                    command.Connection = connection;
                    command.CommandText = commandText;
                    command.ExecuteNonQuery();
                }
                finally
                {
                    _databaseProvider.ReleaseConnection(connection);
                }
            }
        }
 internal void AddTable(string tableName)
 {
     tableName = Qoute(tableName);
     _currentTableInfo = GetTableInfo(tableName);
     _currentTableStatment = _currentTableInfo == null ? new AddTableStatement(tableName) : null;
     if (_currentTableStatment != null)
         _tableStatments.Add(_currentTableStatment);
 }
        public DataBaseInitializer(string connectionString, IDataBaseProvider databaseProvider, Func<DbCommand> getCommandFunc)
        {
            _databaseProvider = databaseProvider;
            _connectionString = connectionString;
            _getCommandFunc = getCommandFunc;

            _tableStatments = new List<IStatement>();

            _currentTableInfo = null;
            _currentTableStatment = null;

            _registeredCreateTableParseMethods = new List<Tuple<Func<IStatement, bool>, Func<IStatement, string, string>>>();
            _registeredAddFieldParseMethods = new List<Tuple<Func<IField, bool>, Func<IField, string, string>>>();
            _registeredAddConstraintParseMethods = new List<Tuple<Func<IField, bool>, Func<IField, string, string>>>();

            AddParseFunc(_registeredCreateTableParseMethods, x => true, DefaultParseCreateTableStatement, false);
            AddParseFunc(_registeredAddFieldParseMethods, x => true, DefaultParseAddFieldStatement, false);
            AddParseFunc(_registeredAddConstraintParseMethods, x => true, DefaultParseAddConstraintStatement, false);
        }