public static void CleanupBatchData(string batchNumber, IDipsDbContext dbContext) { try { Log.Debug("Deleting database entries for batch {@batch}", batchNumber); var batches = dbContext.Queues.Where(b => b.S_BATCH == batchNumber).ToList(); var vouchers = dbContext.NabChqPods.Where(v => v.S_BATCH == batchNumber); var indexes = dbContext.DbIndexes.Where(i => i.BATCH == batchNumber); foreach (var entry in batches.Select(b => dbContext.Entry(b))) { entry.Reload(); entry.State = EntityState.Deleted; } foreach (var v in vouchers) { dbContext.Entry(v).State = EntityState.Deleted; } foreach (var i in indexes) { dbContext.Entry(i).State = EntityState.Deleted; } dbContext.SaveChanges(); Log.Debug("Deleted database entries for batch {@batch}", batchNumber); } catch (Exception ex) { Log.Debug(ex, "Could not delete database entries for batch {@batch}", batchNumber); throw; } }
public static void CleanupBatchData(string batchNumber, IDipsDbContext dbContext) { try { Log.Debug("Deleting database entries for batch {@batch}", batchNumber); var batches = dbContext.Queues.Where(b => b.S_BATCH == batchNumber).ToList(); var vouchers = dbContext.NabChqPods.Where(v => v.S_BATCH == batchNumber); var indexes = dbContext.DbIndexes.Where(i => i.BATCH == batchNumber); foreach (var entry in batches.Select(b => dbContext.Entry(b))) { entry.Reload(); entry.State = EntityState.Deleted; } foreach (var v in vouchers) { dbContext.Entry(v).State = EntityState.Deleted; } foreach (var i in indexes) { dbContext.Entry(i).State = EntityState.Deleted; } dbContext.SaveChanges(); Log.Debug("Deleted database entries for batch {@batch}", batchNumber); } catch (Exception ex) { Log.Debug(ex, "Could not delete database entries for batch {@batch}", batchNumber); throw; } }
public static void CleanupRequestData(string guidName, IDipsDbContext dbContext) { try { Log.Debug("Deleting database entries for request {@guidName}", guidName); var requests = dbContext.DipsRequest.Where(b => b.guid_name == guidName).ToList(); foreach (var request in requests.Select(b => dbContext.Entry(b))) { request.Reload(); request.State = EntityState.Deleted; } dbContext.SaveChanges(); Log.Debug("Deleted database entries for request {@guidName}", guidName); } catch (Exception ex) { Log.Debug(ex, "Could not delete database entries for request {@guidName}", guidName); throw; } }
public static void CleanupRequestData(string guidName, IDipsDbContext dbContext) { try { Log.Debug("Deleting database entries for request {@guidName}", guidName); var requests = dbContext.DipsRequest.Where(b => b.guid_name == guidName).ToList(); foreach (var request in requests.Select(b => dbContext.Entry(b))) { request.Reload(); request.State = EntityState.Deleted; } dbContext.SaveChanges(); Log.Debug("Deleted database entries for request {@guidName}", guidName); } catch (Exception ex) { Log.Debug(ex, "Could not delete database entries for request {@guidName}", guidName); throw; } }