public bool Save() { bool flag = false; using (DbContextTransaction dbContextTransaction = context.Database.BeginTransaction()) { try { context.SaveChanges(); dbContextTransaction.Commit(); flag = true; } catch (DbUpdateException dbUpdateException1) { DbUpdateException dbUpdateException = dbUpdateException1; RPM_Logs rPMLog = this; rPMLog.Msg = string.Concat(rPMLog.Msg, dbUpdateException.InnerException); dbContextTransaction.Rollback(); } catch (DbEntityValidationException dbEntityValidationException1) { DbEntityValidationException dbEntityValidationException = dbEntityValidationException1; dbContextTransaction.Rollback(); foreach (DbEntityValidationResult entityValidationError in dbEntityValidationException.EntityValidationErrors) { foreach (DbValidationError validationError in entityValidationError.ValidationErrors) { RPM_Logs rPMLog1 = this; rPMLog1.Msg = string.Concat(rPMLog1.Msg, string.Format("Property: {0} Error: {1}\n", validationError.PropertyName, validationError.ErrorMessage)); } } } } return(flag); }
public bool Save() { bool flag = false; using (DbContextTransaction contextTransaction = context.Database.BeginTransaction()) { try { context.SaveChanges(); contextTransaction.Commit(); flag = true; } catch (DbUpdateException ex) { contextTransaction.Rollback(); Msg += (string)(object)ex.InnerException; } catch (DbEntityValidationException ex) { contextTransaction.Rollback(); foreach (DbEntityValidationResult entityValidationError in ex.EntityValidationErrors) { foreach (DbValidationError validationError in entityValidationError.ValidationErrors) { Msg += string.Format("Property: {0} Error: {1}\n", validationError.PropertyName, validationError.ErrorMessage); } } } } return(flag); }