public void Submit() { using (db) { db.SaveChanges(); } }
public void Submit() { try { using (db) { db.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("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) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); e.HelpLink = ve.ErrorMessage; } } throw new ApplicationException(e.HelpLink); } }
public void Submit() { try { db.SaveChanges(); } catch (Exception) { throw; } }
public void Submit() { db.SaveChanges(); }