public void Drop_Table()
        {
            ISqlGenerator gen = new MySqlGenerator(null);
            string        sql = gen.BuildDropTableStatement(Product.Schema);

            Assert.AreEqual("DROP TABLE `products`", sql);
        }
Exemple #2
0
        private void BuildDatabaseContext()
        {
            switch (_dbType)
            {
            case DbDialect.SqlServer:
                var connection   = new SqlConnection(_connectionString);
                var config       = new DapperExtensionsConfiguration(typeof(AutoClassMapper <>), new List <Assembly>(), new SqlServerDialect());
                var sqlGenerator = new SqlGeneratorImpl(config);
                DatabaseSession = new Database(connection, sqlGenerator);
                break;

            case DbDialect.Oracle:
                break;

            case DbDialect.PostgreSql:
                break;

            case DbDialect.SqlCe:
                break;

            case DbDialect.Sqlite:
                break;

            case DbDialect.MySqlDialect:
                var mysqlConnection = new MySqlConnection(_connectionString);
                var mysqlConfig     = new DapperExtensionsConfiguration(typeof(AutoClassMapper <>), new List <Assembly>(), new MySqlDialect());
                var mysqlGenerator  = new MySqlGenerator(mysqlConfig);
                DatabaseSession = new Database(mysqlConnection, mysqlGenerator);
                break;

            default:

                break;
            }
        }
        public void Select_ColumnList_Specified()
        {
            SubSonic.SqlQuery qry       = new Select("productid", "productname").From(Product.Schema);
            ISqlGenerator     generator = new MySqlGenerator(qry);

            string selectList = generator.GenerateCommandLine();

            Assert.AreEqual("SELECT `products`.`ProductID`, `products`.`ProductName`\r\n", selectList);
        }
        public void Remove_Column()
        {
            TableSchema.Table       productSchema = Product.Schema;
            TableSchema.TableColumn column        = productSchema.GetColumn("ProductName");

            ISqlGenerator generator = new MySqlGenerator(null);
            string        sql       = generator.BuildDropColumnStatement(productSchema, column);

            Assert.AreEqual("ALTER TABLE `products` DROP COLUMN `ProductName`", sql);
        }
        public void Alter_Column()
        {
            TableSchema.Table       productSchema = Product.Schema;
            TableSchema.TableColumn column        = productSchema.GetColumn("ProductName");
            column.MaxLength = 150;

            ISqlGenerator generator = new MySqlGenerator(null);
            string        sql       = generator.BuildAlterColumnStatement(column);

            Assert.AreEqual("ALTER TABLE `products` ALTER COLUMN `ProductName` nvarchar(150) NOT NULL", sql);
        }
        public void Add_Column()
        {
            TableSchema.Table       productSchema = Product.Schema;
            TableSchema.TableColumn column        = new TableSchema.TableColumn(productSchema);
            column.ColumnName = "Address4";
            column.DataType   = DbType.String;
            column.MaxLength  = 50;
            column.IsNullable = true;

            ISqlGenerator generator = new MySqlGenerator(null);
            string        sql       = generator.BuildAddColumnStatement(Product.Schema, column);

            Assert.AreEqual("ALTER TABLE `products` ADD `Address4` nvarchar(50) NULL", sql);
        }
        public void Create_Table()
        {
            TableSchema.Table testSchema = new TableSchema.Table("Southwind", "ShippingCarriers");
            testSchema.AddPrimaryKeyColumn("Id");
            testSchema.AddColumn("Name", DbType.String, 50, false);
            testSchema.AddColumn("Description", DbType.String, 100, false);

            ISqlGenerator generator = new MySqlGenerator(null);
            string        sql       = generator.BuildCreateTableStatement(testSchema);

            Assert.AreEqual(
                "CREATE TABLE `ShippingCarriers` (\r\n  `Id` INTEGER NOT NULL AUTO_INCREMENT,\r\n  `Name` nvarchar(50) NOT NULL,\r\n  `Description` nvarchar(100) NOT NULL,\r\n  PRIMARY KEY (`Id`) \r\n)",
                sql);
        }
Exemple #8
0
        public void Generate(ProjectsConfigs prjsConfig)
        {
            var prj = prjsConfig.DefaultProject;

            switch (prj.DbConfig.Type)
            {
            case DatabaseTypes.MySQL:
            {
                var generator = new MySqlGenerator(prj);
                generator.GenerateModels();
                generator.GenerateRepositories();

                break;
            }

            case DatabaseTypes.SQLServer:
            {
                var modelGenerator = new SqlServerModelGenerator(prj);
                modelGenerator.GenerateModels();

                break;
            }
            }
        }
 public void Setup()
 {
     Generator = new MySqlGenerator();
 }
 public void Setup()
 {
     _generator = new MySqlGenerator();
 }
Exemple #11
0
 public void SetUp()
 {
     generator = new MySqlGenerator();
 }
Exemple #12
0
 public BaseDao()
 {
     DbConnection = new MySqlConnection(Utils.GetConfig("MySql", ""));
     SqlGenerator = new MySqlGenerator();
 }