コード例 #1
0
        private static void Run(DBName dBName)
        {
            var connString       = _configuration.GetConnectionString(dBName.ToString());
            var scriptFolderPath = $"./Scripts/{dBName.ToString()}";

            EnsureDatabase.For.PostgresqlDatabase(connString);

            var upgradeBuilder = DeployChanges.To
                                 .PostgresqlDatabase(connString)
                                 .WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "Scripts"), new SqlScriptOptions {
                RunGroupOrder = 1, ScriptType = ScriptType.RunOnce
            })
                                 .WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "SeedData"), new SqlScriptOptions {
                RunGroupOrder = 2, ScriptType = ScriptType.RunOnce
            });

            if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
            {
                upgradeBuilder.WithScriptsFromFileSystem(Path.Combine(scriptFolderPath, "SampleData"), new SqlScriptOptions {
                    RunGroupOrder = 3, ScriptType = ScriptType.RunOnce
                });
            }
            var upgrader = upgradeBuilder.LogToAutodetectedLog().Build();

            upgrader.PerformUpgrade();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: stephennp/crm
        private static void Run(DBName dBName)
        {
            var connString       = _configuration.GetConnectionString(dBName.ToString());
            var scriptFolderPath = $"./Scripts/{dBName.ToString()}";

            var upgrader = DeployChanges.To
                           .PostgresqlDatabase(connString)
                           .WithScriptsFromFileSystem(scriptFolderPath, new SqlScriptOptions
            {
                RunGroupOrder = DbUpDefaults.DefaultRunGroupOrder + 1
            })
                           .LogToAutodetectedLog()
                           .Build();

            var result = upgrader.PerformUpgrade();
        }
コード例 #3
0
        public static DbContext Create(DBName dbName)
        {
            DbContext dbContext = CallContext.GetData(dbName.ToString()) as DbContext;

            if (dbContext == null)
            {
                lock (locker)
                {
                    if (dbContext == null)
                    {
                        switch (dbName)
                        {
                        case DBName.ChannelDB:
                            //dbContext = new ChannelEntities();
                            //CallContext.SetData(dbName.ToString(), dbContext);
                            break;

                        case DBName.MpConfigDB:
                            //dbContext = new MPDBEntities();
                            //CallContext.SetData(dbName.ToString(), dbContext);
                            break;

                        case DBName.ReservationDB:
                            //dbContext = new yudingEntities();
                            //CallContext.SetData(dbName.ToString(), dbContext);
                            break;

                        case DBName.ITicketDB:
                            dbContext = new iticketDB();
                            CallContext.SetData(dbName.ToString(), dbContext);
                            break;

                        default:
                            dbContext = null;
                            break;
                        }
                    }
                }
            }
            return(dbContext);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: 666marat666/Diplom
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     switch (comboBox1.SelectedItem.ToString())
     {
         case "SQLite":
             SelectedDB = DBName.SQLite;
             SDB.Text = SelectedDB.ToString();
             break;
         case "MySql":
             SelectedDB = DBName.MySql;
             SDB.Text = SelectedDB.ToString();
             break;
         case "MSSQL":
             SelectedDB = DBName.MSSQL;
             SDB.Text = SelectedDB.ToString();
             break;
         default:
             SelectedDB = DBName.SQLite;
             SDB.Text = SelectedDB.ToString();
             break;
     }
 }
コード例 #5
0
 private DapperInfrastructure.DB GetNewDB(DBName dbName)
 {
     return(DapperInfrastructure.DB.New(dbName.ToString()));
 }