Ejemplo n.º 1
0
 private void DeleteDatabaseObjects()
 {
     using (var entityManager = new CountriesEntityManager()) {
         try {
             var sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Continent] WHERE ([Abbreviation] = '{continentAbbreviationCreate}');");
             entityManager.ExecuteScalarSql(sqlCommand);
             sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Continent] WHERE ([Abbreviation] = '{continentAbbreviationUpdate}');");
             entityManager.ExecuteScalarSql(sqlCommand);
             sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Continent] WHERE ([Abbreviation] = '{continentAbbreviationDelete}');");
             entityManager.ExecuteScalarSql(sqlCommand);
         }
         catch (Exception e) {
             Log.Error($"[ThreadID: {Thread.CurrentThread.ManagedThreadId}] {ObjectExtensions.CurrentMethodName()} {e.VerboseExceptionString()}");
         }
     }
 }
Ejemplo n.º 2
0
 private void DeleteDatabaseObjects()
 {
     using (var entityManager = new CountriesEntityManager()) {
         try {
             var sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CallingCode] WHERE ([CallingCodeNumber] = {callingCodeNumberCreate});");
             entityManager.ExecuteScalarSql(sqlCommand);
             sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CallingCode] WHERE ([CallingCodeNumber] = {callingCodeNumberUpdate});");
             entityManager.ExecuteScalarSql(sqlCommand);
             sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CallingCode] WHERE ([CallingCodeNumber] = {callingCodeNumberUpdate2});");
             entityManager.ExecuteScalarSql(sqlCommand);
             sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CallingCode] WHERE ([CallingCodeNumber] = {callingCodeNumberDelete});");
             entityManager.ExecuteScalarSql(sqlCommand);
         }
         catch (Exception e) {
             Log.Error($"[ThreadID: {Thread.CurrentThread.ManagedThreadId}] {ObjectExtensions.CurrentMethodName()} {e.VerboseExceptionString()}");
         }
     }
 }
Ejemplo n.º 3
0
        private void DeleteDatabaseObjects()
        {
            using (var entityManager = new CountriesEntityManager()) {
                try {
                    var sqlCommand           = new SqlCommand($"SELECT [Id] FROM [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeCreate}');");
                    int currencyCodeCreateId = Convert.ToInt32(entityManager.ExecuteScalarSql(sqlCommand));
                    if (currencyCodeCreateId > 0)
                    {
                        sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CountryCurrency] WHERE ([CurrencyId] = '{currencyCodeCreateId}');");
                        entityManager.ExecuteScalarSql(sqlCommand);
                    }
                    sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeCreate}');");
                    entityManager.ExecuteScalarSql(sqlCommand);

                    sqlCommand = new SqlCommand($"SELECT [Id] FROM [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeUpdate}');");
                    int currencyCodeUpdateId = Convert.ToInt32(entityManager.ExecuteScalarSql(sqlCommand));
                    if (currencyCodeUpdateId > 0)
                    {
                        sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CountryCurrency] WHERE ([CurrencyId] = '{currencyCodeUpdateId}');");
                        entityManager.ExecuteScalarSql(sqlCommand);
                    }
                    sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeUpdate}');");
                    entityManager.ExecuteScalarSql(sqlCommand);

                    sqlCommand = new SqlCommand($"SELECT [Id] FROM [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeDelete}');");
                    int currencyCodeDeleteId = Convert.ToInt32(entityManager.ExecuteScalarSql(sqlCommand));
                    if (currencyCodeDeleteId > 0)
                    {
                        sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[CountryCurrency] WHERE ([CurrencyId] = '{currencyCodeDeleteId}');");
                        entityManager.ExecuteScalarSql(sqlCommand);
                    }
                    sqlCommand = new SqlCommand($"DELETE [Countries].[dbo].[Currency] WHERE ([Code] = '{currencyCodeDelete}');");
                    entityManager.ExecuteScalarSql(sqlCommand);
                }
                catch (Exception e) {
                    Log.Error($"[ThreadID: {Thread.CurrentThread.ManagedThreadId}] {ObjectExtensions.CurrentMethodName()} {e.VerboseExceptionString()}");
                }
            }
        }