示例#1
0
        private void DeleteAllTables(ComponentMetastore componentMetastore)
        {
            var tables = this.GetTables(componentMetastore);

            using (var connection = CreateDbConnection(componentMetastore))
            {
                foreach (var table in tables)
                {
                    using (var command = new SqlCommand(string.Format("DROP TABLE {0}", table), connection))
                    {
                        command.ExecuteNonQuery();
                    }
                }
            }
        }
示例#2
0
        private Collection <string> GetTables(ComponentMetastore componentMetastore)
        {
            var tables = new Collection <string>();

            using (var connection = CreateDbConnection(componentMetastore))
                using (var command = new SqlCommand("select name from sys.objects where type = 'U'", connection))
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            tables.Add(reader.GetString(0));
                        }
                    }

            return(tables);
        }
示例#3
0
        private SqlConnection CreateDbConnection(ComponentMetastore metastore)
        {
            SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder
            {
                DataSource         = metastore.Server,
                InitialCatalog     = metastore.Database,
                UserID             = metastore.User,
                Password           = metastore.Password,
                IntegratedSecurity = false,
            };

            var connection = new SqlConnection(connectionString.ConnectionString);

            connection.Open();
            return(connection);
        }
示例#4
0
 private void ValidateTable(string tableName, ComponentMetastore componentMetastore)
 {
     throw new NotImplementedException();
 }
示例#5
0
 private void DeleteAllTables(ComponentMetastore componentMetastore)
 {
     var tables = this.GetTables(componentMetastore);
     using (var connection = CreateDbConnection(componentMetastore))
     {
         foreach (var table in tables)
         using (var command = new SqlCommand(string.Format("DROP TABLE {0}", table), connection))
         {
             command.ExecuteNonQuery();
         }
     }
 }
示例#6
0
        private Collection<string> GetTables(ComponentMetastore componentMetastore)
        {
            var tables = new Collection<string>();
             
            using (var connection = CreateDbConnection(componentMetastore))
            using (var command = new SqlCommand("select name from sys.objects where type = 'U'", connection))
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    tables.Add(reader.GetString(0));
                }
            }

            return tables;
        }
示例#7
0
        private SqlConnection CreateDbConnection(ComponentMetastore metastore)
        {
            SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder
            {
                DataSource = metastore.Server,
                InitialCatalog = metastore.Database,
                UserID = metastore.User,
                Password = metastore.Password,
                IntegratedSecurity = false,
            };

            var connection = new SqlConnection(connectionString.ConnectionString);
            connection.Open();
            return connection;
        }
示例#8
0
 private void ValidateTable(string tableName, ComponentMetastore componentMetastore)
 {
     throw new NotImplementedException();
 }