Beispiel #1
0
        private static void MySQLCreateScriptTest()
        {
            MySQLDataContext mySQLDataContext = new MySQLDataContextFactory().CreateDataContext(_config["ConnectionStrings:MySQL"], "hammurabi");


            List <Table> tables =
                mySQLDataContext
                .Database
                .Schemas
                .SelectMany(s => s.Tables)
                .ToList();

            List <View> views =
                mySQLDataContext
                .Database
                .Schemas
                .SelectMany(s => s.Views)
                .ToList();

            Console.WriteLine("TABLES:");
            tables.ForEach(t =>
            {
                Console.WriteLine(mySQLDataContext.GetCreateScriptForTable(t) + "\n-------------------------------------------------------------------\n");
            });


            Console.WriteLine("VIEWS:");
            views.ForEach(v =>
            {
                Console.WriteLine(mySQLDataContext.GetCreateScriptForView(v) + "\n-------------------------------------------------------------------\n");
            });

            Console.WriteLine("DATABASE:");
            Console.WriteLine(mySQLDataContext.GetCreateScriptForDatabase());
        }
Beispiel #2
0
        private static void MySQLTimeTest(int iterations)
        {
            Stopwatch   sw    = new Stopwatch();
            List <long> times = new List <long>();

            for (int i = 0; i < iterations; i++)
            {
                sw.Start();
                MySQLDataContext mySQLDataContext = new MySQLDataContextFactory().CreateDataContext(_config["ConnectionStrings:MySQL"], "hammurabi");
                sw.Stop();
                times.Add(sw.ElapsedMilliseconds);
                sw.Reset();
            }

            times.ForEach(t => Console.WriteLine(t));
        }
Beispiel #3
0
        private static void MySQLPrintTest()
        {
            Stopwatch sw1 = new Stopwatch();

            sw1.Start();
            MySQLDataContext mySQLDataContext = new MySQLDataContextFactory().CreateDataContext(_config["ConnectionStrings:MySQL"], "hammurabi");

            sw1.Stop();


            foreach (Schema schema in mySQLDataContext.Database.Schemas)
            {
                Console.WriteLine("SCHEMA: " + schema.Name);
                foreach (Table table in schema.Tables)
                {
                    Console.WriteLine("\tTABLE: " + table.Name + "\n\tno. rows: " + mySQLDataContext.GetRowCountForTable(table));
                    Console.WriteLine("\t\tCOLUMNS:");
                    foreach (Column column in table.Columns)
                    {
                        Console.WriteLine(string.Format("\t\t{0} is {1} of size {2}. PK:{3}, FK:{4}. NULLABLE: {5}", column.Name, column.Value.DataType, column.Value.DataSize, column.IsPrimaryKey, column.IsForeignKey, column.IsNullable));
                    }
                    Console.WriteLine("\t\tIndexes:");
                    foreach (Index index in table.Indexes)
                    {
                        Console.WriteLine("\t\t{0} on {1}", index.Name, index.IndexedColumns.Select(c => c.Name).Aggregate((n1, n2) => n1 + ", " + n2));
                    }
                }

                foreach (View view in schema.Views)
                {
                    Console.WriteLine("\tVIEW: " + view.Name);
                    Console.WriteLine("\t\tCOLUMNS:");
                    foreach (Column column in view.Columns)
                    {
                        Console.WriteLine(string.Format("\t\t{0} is {1} of size {2}. PK:{3}, FK:{4}. NULLABLE: {5}", column.Name, column.Value.DataType, column.Value.DataSize, column.IsPrimaryKey, column.IsForeignKey, column.IsNullable));
                    }
                }
            }

            Console.WriteLine(sw1.ElapsedMilliseconds);
        }
Beispiel #4
0
 private static void MySQLOneOff()
 {
     MySQLDataContext mySQLDataContext = new MySQLDataContextFactory().CreateDataContext(_config["ConnectionStrings:MySQL"], "hammurabi");
 }