예제 #1
0
 /// <exception cref="OperationFailedException" />
 static void DoDestroyStructure(bool inTransaction)
 {
     HConsole.PrintOperation("Уничтожение структуры данных");
     QueryTextBuilder.Clear();
     AppendQueryLine("BEGIN TRY");
     ComposeDropTablesScript();
     AppendQueryLine("END TRY");
     AppendQueryLine("BEGIN CATCH");
     AppendQueryLine("THROW");
     AppendQueryLine("END CATCH");
     try
     {
         using (var db = new DBC(false))
         {
             if (inTransaction)
             {
                 db.Database.BeginTransaction();
             }
             db.Database.ExecuteSqlCommand(QueryTextBuilder.ToString());
             if (inTransaction)
             {
                 db.Database.CommitTransaction();
             }
         }
     }
     catch (Exception e)
     {
         throw new OperationFailedException(e.Message);
     }
 }
예제 #2
0
파일: DeleteData.cs 프로젝트: vese/BookLib
 /// <exception cref="OperationFailedException" />
 static void DoDeleteData(bool inTransaction)
 {
     HConsole.PrintOperation("Удаление данных (очистка таблиц)");
     QueryTextBuilder.Clear();
     AppendQueryLine("BEGIN TRY");
     ComposeDeleteTablesScript();
     AppendQueryLine("END TRY");
     AppendQueryLine("BEGIN CATCH");
     AppendQueryLine("THROW");
     AppendQueryLine("END CATCH");
     try
     {
         using (var db = new DBC(false))
         {
             if (inTransaction)
             {
                 db.Database.BeginTransaction();
             }
             db.Database.ExecuteSqlCommand(QueryTextBuilder.ToString());
             if (inTransaction)
             {
                 db.Database.CommitTransaction();
             }
         }
     }
     catch (Exception e)
     {
         throw new OperationFailedException(e.Message);
     }
 }
예제 #3
0
파일: FillTest.cs 프로젝트: vese/BookLib
 /// <exception cref="OperationFailedException" />
 static void DoFillTest(bool withCleanup)
 {
     try
     {
         using (var db = new DBC(false))
         {
             db.Database.BeginTransaction();
             if (withCleanup)
             {
                 HConsole.PrintOperation("Предварительная очистка всех таблиц");
                 QueryTextBuilder.Clear();
                 AppendQueryLine("BEGIN TRY");
                 ComposeDeleteTablesScript();
                 AppendQueryLine("END TRY");
                 AppendQueryLine("BEGIN CATCH");
                 AppendQueryLine("THROW");
                 AppendQueryLine("END CATCH");
                 db.Database.ExecuteSqlCommand(QueryTextBuilder.ToString());
             }
             HConsole.PrintOperation("Добавление тестовых данных (наполнение таблиц)");
             FillTablesWithTest(db);
             db.SaveChanges();
             db.Database.CommitTransaction();
         }
     }
     catch (Exception e)
     {
         throw new OperationFailedException(e.Message);
     }
 }
예제 #4
0
 /// <exception cref="OperationFailedException" />
 static void DoCreateStructure()
 {
     HConsole.PrintOperation("Создание структуры данных (\"Database.EnsureCreated\")");
     try
     {
         using (var db = new DBC(true))
         {}
     }
     catch (Exception e)
     {
         throw new OperationFailedException(e.Message);
     }
 }