コード例 #1
0
        private void RunMigration(string localDbPath, string[] tablesToIgnoreOrAppend, string targetConnectionString, Scope scope, bool removeTempFiles)
        {
            using (var repository = new DB4Repository($"Data Source={localDbPath};Max Database Size=4000"))
            {
                var scriptRoot = Path.GetTempFileName();
                var tempScript = scriptRoot + ".sqltb";
                var generator  = new Generator4(repository, tempScript);

                if (scope == Scope.DataOnlyForSqlServerIgnoreIdentity)
                {
                    //Ignore all tables except the ones in tablesToAppend
                    var tables = repository.GetAllTableNames();
                    var list   = tables.Except(tablesToIgnoreOrAppend.ToList());
                    generator.ExcludeTables(list.ToList());
                }
                else
                {
                    generator.ExcludeTables(tablesToIgnoreOrAppend.ToList());
                }

                generator.ScriptDatabaseToFile(scope);
                using (var serverRepository = new ServerDBRepository4(targetConnectionString))
                {
                    try
                    {
                        //Handles large exports also...
                        if (File.Exists(tempScript)) // Single file
                        {
                            serverRepository.ExecuteSqlFile(tempScript);
                            if (removeTempFiles)
                            {
                                TryDeleteFile(tempScript);
                            }
                        }
                        else // possibly multiple files - tmp2BB9.tmp_0.sqlce
                        {
                            for (var i = 0; i < 400; i++)
                            {
                                var testFile = string.Format("{0}_{1}{2}", scriptRoot, i.ToString("D4"), ".sqltb");
                                if (File.Exists(testFile))
                                {
                                    serverRepository.ExecuteSqlFile(testFile);
                                    if (removeTempFiles)
                                    {
                                        TryDeleteFile(testFile);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        CreateBlockFile(localDbPath, ex);
                        throw;
                    }
                }
            }
        }
コード例 #2
0
 public void TestGraphSortServer()
 {
     using (IRepository sourceRepository = new ServerDBRepository4(serverConnectionString))
     {
         var generator = new Generator4(sourceRepository, @"C:\temp\testAMS40.sqlce");
         generator.ExcludeTables(new System.Collections.Generic.List <String>());
     }
 }
コード例 #3
0
 public void TestGraphSortComplex()
 {
     using (IRepository sourceRepository = new DB4Repository(sdfConnectionString2))
     {
         var generator = new Generator4(sourceRepository, @"C:\temp\testPZ.sqlce");
         generator.ExcludeTables(new System.Collections.Generic.List <String>());
     }
 }
コード例 #4
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestServerExportDotInTable()
 {
     string path = @"C:\temp\API2012.sqlce";
     using (IRepository sourceRepository = new ServerDBRepository4(serverApiTestConnectionString))
     {
         var generator = new Generator4(sourceRepository, path);
         generator.ExcludeTables(new List<string>());
     }
 }
コード例 #5
0
 public void TestServerHierarchyIdSqlCe()
 {
     using (IRepository sourceRepository = new ServerDBRepository4(serverHIDConnectionString))
     {
         var exclusions = new List <string>();
         var generator  = new Generator4(sourceRepository, @"C:\code\test2.sql");
         generator.ExcludeTables(exclusions);
         generator.ScriptDatabaseToFile(Scope.SchemaData);
     }
 }
コード例 #6
0
        public void TestServerExportConstrainsIssue()
        {
            string path = @"C:\temp\Baseball.sqlce";

            using (IRepository sourceRepository = new ServerDBRepository4(BaseballTestConnectionString))
            {
                var generator = new Generator4(sourceRepository, path);
                generator.ExcludeTables(new List <string>());
            }
        }
コード例 #7
0
        public void TestServerExportDotInTable()
        {
            string path = @"C:\temp\API2012.sqlce";

            using (IRepository sourceRepository = new ServerDBRepository4(serverApiTestConnectionString))
            {
                var generator = new Generator4(sourceRepository, path);
                generator.ExcludeTables(new List <string>());
            }
        }
コード例 #8
0
        public void TestExportToSqlServer2()
        {
            var path = @"C:\temp\testum.sql";

            using (var sourceRepository = new DB4Repository(umbracoConn))
            {
                var generator = new Generator4(sourceRepository, path, false, false, false);
                generator.ExcludeTables(new List <string>());
                generator.ScriptDatabaseToFile(Scope.SchemaData);
            }
        }
コード例 #9
0
        public void TestServerExportToSqlite()
        {
            var path = @"C:\temp\testAW2012.sql";

            using (var sourceRepository = new ServerDBRepository4(serverDefConnectionString, true))
            {
                var generator = new Generator4(sourceRepository, path, false, false, true);
                generator.ExcludeTables(new List <string>());
                generator.ScriptDatabaseToFile(Scope.SchemaDataSQLite);
            }
        }
コード例 #10
0
        public void TestServerExportUniqueIssue()
        {
            string path = @"C:\temp\E2E.sqlce";

            using (IRepository sourceRepository = new ServerDBRepository4(E2EConnectionString))
            {
                var generator = new Generator4(sourceRepository, path);
                generator.ExcludeTables(new List <string>());
                generator.GenerateTableScript("OneToOneSeparateFKDependent");
                var test = generator.GeneratedScript;
            }
        }
コード例 #11
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestServerExportUniqueIssue()
 {
     string path = @"C:\temp\E2E.sqlce";
     using (IRepository sourceRepository = new ServerDBRepository4(E2EConnectionString))
     {
         var generator = new Generator4(sourceRepository, path);
         generator.ExcludeTables(new List<string>());
         generator.GenerateTableScript("OneToOneSeparateFKDependent");
         var test = generator.GeneratedScript;
     }
 }
コード例 #12
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestServerExportConstrainsIssue()
 {
     string path = @"C:\temp\Baseball.sqlce";
     using (IRepository sourceRepository = new ServerDBRepository4(BaseballTestConnectionString))
     {
         var generator = new Generator4(sourceRepository, path);
         generator.ExcludeTables(new List<string>());
     }
 }
コード例 #13
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestGraphSortServer()
 {
     using (IRepository sourceRepository = new ServerDBRepository4(serverConnectionString))
     {
         var generator = new Generator4(sourceRepository, @"C:\temp\testAMS40.sqlce");
         generator.ExcludeTables(new System.Collections.Generic.List<String>());
     }
 }
コード例 #14
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestGraphSortComplex()
 {
     using (IRepository sourceRepository = new DB4Repository(sdfConnectionString2))
     {
         var generator = new Generator4(sourceRepository, @"C:\temp\testPZ.sqlce");
         generator.ExcludeTables(new System.Collections.Generic.List<String>());
     }
 }
コード例 #15
0
ファイル: Test.cs プロジェクト: inickvel/SqlCeToolbox
 public void TestServerHierarchyIdSqlCe()
 {
     using (IRepository sourceRepository = new ServerDBRepository4(serverHIDConnectionString))
     {
         var exclusions = new List<string>();
         var generator = new Generator4(sourceRepository, @"C:\code\test2.sql");
         generator.ExcludeTables(exclusions);
         generator.ScriptDatabaseToFile(Scope.SchemaData);
     }
 }