コード例 #1
0
        public void CanCreateDBScriptWithDateTimePrecision()
        {
            if (Version < new Version(5, 6, 5)) return;

             MySqlConnection c = new MySqlConnection(conn.ConnectionString);
             c.Open();

             var script = new MySqlScript(c);
             using (var ctx = new datesTypesEntities())
             {
               MySqlCommand query = new MySqlCommand("Create database test_types", c);
               query.Connection = c;
               query.ExecuteNonQuery();
               c.ChangeDatabase("test_types");

               script.Query = ctx.CreateDatabaseScript();
               script.Execute();

               query = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + c.Database + "' and table_name = 'Products' and column_name ='DateTimeWithPrecision'", c);
               query.Connection = c;
               MySqlDataReader reader = query.ExecuteReader();
               while (reader.Read())
               {
              Assert.AreEqual("DateTimeWithPrecision", reader[0].ToString());
              Assert.AreEqual("NO", reader[1].ToString());
              Assert.AreEqual("datetime", reader[2].ToString());
              Assert.AreEqual("3", reader[3].ToString());
               }
               reader.Close();
               ctx.DeleteDatabase();
               c.Close();
             }
        }
コード例 #2
0
        public void CanCreateDBScriptWithDateTimePrecision()
        {
            if (Version < new Version(5, 6, 5))
            {
                return;
            }

            MySqlConnection c = new MySqlConnection(conn.ConnectionString);

            c.Open();

            var script = new MySqlScript(c);

            using (var ctx = new datesTypesEntities())
            {
                MySqlCommand query = new MySqlCommand("Create database test_types", c);
                query.Connection = c;
                query.ExecuteNonQuery();
                c.ChangeDatabase("test_types");

                script.Query = ctx.CreateDatabaseScript();
                script.Execute();

                query            = new MySqlCommand("Select Column_name, Is_Nullable, Data_Type, DateTime_Precision from information_schema.Columns where table_schema ='" + c.Database + "' and table_name = 'Products' and column_name ='DateTimeWithPrecision'", c);
                query.Connection = c;
                MySqlDataReader reader = query.ExecuteReader();
                while (reader.Read())
                {
                    Assert.AreEqual("DateTimeWithPrecision", reader[0].ToString());
                    Assert.AreEqual("NO", reader[1].ToString());
                    Assert.AreEqual("datetime", reader[2].ToString());
                    Assert.AreEqual("3", reader[3].ToString());
                }
                reader.Close();
                ctx.DeleteDatabase();
                c.Close();
            }
        }