/// <summary> /// Static method to empty Bank /// </summary> public static void ClearBank(ApplicationSettings application) { int originalRows = 0; int newRows = 0; try { logger.Info($"Started clearing bank rows"); using (BusinessAccountingEntities context = new BusinessAccountingEntities()) { var queryTransaction = (from row in context.Bank select row).ToList(); originalRows = queryTransaction.Count; context.Database.ExecuteSqlCommand("truncate table [ODS].[Bank]"); context.SaveChanges(); newRows = queryTransaction.Count; if (newRows == 0) { logger.Info($"Successfully cleared ODS. Original rows [{originalRows.ToString()}]" + $"; New rows [{newRows.ToString()}]"); logger.Info($"Finished clearing Bank"); } } } catch (Exception e) { logger.Error($"Exception while trying to clear bank rows. Exception [{e.ToString()}]"); throw; } }
/// <summary> /// Static method to clear DIM and SRC tables /// </summary> public static void ClearDIMSRCEntity(string entityName) { try { logger.Info($"Started clearing [{entityName}] rows"); using (BusinessAccountingEntities context = new BusinessAccountingEntities()) { context.Database.ExecuteSqlCommand($"truncate table {entityName}"); context.SaveChanges(); logger.Info($"Successfully cleared rows from {entityName}"); } } catch (Exception e) { logger.Error($"Exception while trying to clear rows from {entityName}. Exception [{e.ToString()}]"); throw; } }