public static void DeleteAll() { using (var db = new CommBankStatementPDF.Data.CBAStatementsEntities()) { db.Transactions.RemoveRange(db.Transactions); db.SaveChanges(); } }
public static void Save(IList <Prototype> transactions) { try { using (var db = new CommBankStatementPDF.Data.CBAStatementsEntities()) { var customers = db.Set <Transactions>(); foreach (var item in transactions) { customers.Add(new Transactions { Source = item.Biller, AccountType = item.AccountType.ToString(), Amount = item.Amount.GetValueOrDefault(), Biller = item.Biller, Date = item.Date, Filename = item.SourceFile }); } db.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Trace.WriteLine(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { Trace.WriteLine(string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } } throw; } }