Ejemplo n.º 1
0
        public void RunSqlite()
        {
            using (var connection = new SqliteConnection("Data Source=:memory:"))
            {
                connection.Open();

                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "CREATE TABLE Test(Value);";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Test VALUES(1);";
                    cmd.ExecuteNonQuery();
                }
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText =
                        "SELECT [type], [name], [tbl_name], [rootpage], [sql], [rowid] FROM [main].[sqlite_master] WHERE [type] LIKE 'table'";
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            System.Console.WriteLine(dr[2].ToString());
                        }
                    }
                }

                var databaseReader = new DatabaseSchemaReader.DatabaseReader(connection);
                var schema = databaseReader.ReadAll();
                var tableList = databaseReader.TableList();
                var tables = databaseReader.AllTables();
                var views = databaseReader.AllViews();
                Assert.NotEmpty(tableList);
            }
        }
Ejemplo n.º 2
0
        public void RunSqlite()
        {
            using (var connection = new SqliteConnection("Data Source=:memory:"))
            {
                connection.Open();

                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = "CREATE TABLE Test(Value);";
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "INSERT INTO Test VALUES(1);";
                    cmd.ExecuteNonQuery();
                }
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText =
                        "SELECT [type], [name], [tbl_name], [rootpage], [sql], [rowid] FROM [main].[sqlite_master] WHERE [type] LIKE 'table'";
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            System.Console.WriteLine(dr[2].ToString());
                        }
                    }
                }

                var databaseReader = new DatabaseSchemaReader.DatabaseReader(connection);
                var schema         = databaseReader.ReadAll();
                var tableList      = databaseReader.TableList();
                var tables         = databaseReader.AllTables();
                var views          = databaseReader.AllViews();
                Assert.NotEmpty(tableList);
            }
        }
Ejemplo n.º 3
0
 public void RunTableList()
 {
     using (var connection = new SqlConnection(Northwind))
     {
         var dr        = new DatabaseSchemaReader.DatabaseReader(connection);
         var schema    = dr.ReadAll();
         var tableList = dr.TableList();
         var tables    = dr.AllTables();
         var views     = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 4
0
 public void RunTableList()
 {
     using (var connection = new SqlConnection(Northwind))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         var schema = dr.ReadAll();
         var tableList = dr.TableList();
         var tables = dr.AllTables();
         var views = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 5
0
 public void RunTableList()
 {
     //couldn't get package to restore.
     using (var connection = new Npgsql.NpgsqlConnection(PostgreSql))
     {
         var dr        = new DatabaseSchemaReader.DatabaseReader(connection);
         var schema    = dr.ReadAll();
         var tableList = dr.TableList();
         var tables    = dr.AllTables();
         var views     = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 6
0
 public void RunTableList()
 {
     //couldn't get package to restore.
     using (var connection = new Npgsql.NpgsqlConnection(PostgreSql))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         var schema = dr.ReadAll();
         var tableList = dr.TableList();
         var tables = dr.AllTables();
         var views = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 7
0
 public void RunTableList()
 {
     using (var connection = new MySql.Data.MySqlClient.MySqlConnection(MySql))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         dr.Owner = "sakila";
         var schema = dr.ReadAll();
         var tableList = dr.TableList();
         var tables = dr.AllTables();
         var views = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 8
0
 public void RunTableList()
 {
     using (var connection = new MySql.Data.MySqlClient.MySqlConnection(MySql))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         dr.Owner = "sakila";
         var schema    = dr.ReadAll();
         var tableList = dr.TableList();
         var tables    = dr.AllTables();
         var views     = dr.AllViews();
         Assert.NotEmpty(tableList);
     }
 }
Ejemplo n.º 9
0
 public void RunTableList()
 {
     using (var connection = new SqlConnection(Northwind))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         //Microsoft.Data.SqlClient needs a longer timeout than System.Data.SqlClient (on the stored procedure query)
         dr.CommandTimeout = 60;
         var schema    = dr.ReadAll();
         var tableList = dr.TableList();
         var tables    = dr.AllTables();
         var views     = dr.AllViews();
         Assert.IsTrue(tableList.Count > 0);
     }
 }
Ejemplo n.º 10
0
        public void RunTableListWithTransaction()
        {
            using (var connection = new SqlConnection(Northwind))
            {
                connection.Open();
                using (var txn = connection.BeginTransaction())
                {
                    var dr        = new DatabaseSchemaReader.DatabaseReader(txn);
                    var schema    = dr.ReadAll();
                    var tableList = dr.TableList();
                    var tables    = dr.AllTables();
                    var views     = dr.AllViews();
                    Assert.NotEmpty(tableList);

                    txn.Rollback();
                }
            }
        }
Ejemplo n.º 11
0
 public void RunTableList()
 {
     //couldn't get package to restore.
     using (var connection = new Npgsql.NpgsqlConnection(PostgreSql))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         try
         {
             var schema    = dr.ReadAll();
             var tableList = dr.TableList();
             var tables    = dr.AllTables();
             var views     = dr.AllViews();
             Assert.IsTrue(tableList.Count > 0);
         }
         catch (System.Net.Sockets.SocketException)
         {
             Console.WriteLine("PostgreSql not installed on this machine");
         }
     }
 }
Ejemplo n.º 12
0
 public void RunTableList()
 {
     using (var connection = new MySql.Data.MySqlClient.MySqlConnection(MySql))
     {
         var dr = new DatabaseSchemaReader.DatabaseReader(connection);
         dr.Owner = "sakila";
         try
         {
             var schema    = dr.ReadAll();
             var tableList = dr.TableList();
             var tables    = dr.AllTables();
             var views     = dr.AllViews();
             Assert.IsTrue(tableList.Count > 0);
         }
         catch (System.Resources.MissingManifestResourceException)
         {
             Console.WriteLine("MySql Core error");
             //System.Resources.MissingManifestResourceException :
             //Could not find any resources appropriate for the specified culture or the neutral culture.
             //Make sure "MySql.Data.Resources.resources" was correctly embedded or linked into assembly "MySql.Data.Core" at compile time,
             //or that all the satellite assemblies required are loadable and fully signed.
         }
     }
 }