> /// <summary> > /// Cancel Changes on the current connected context > /// </summary> > public virtual void AbortChanges() > { > // Create a new context instance from scratch > Context.Dispose(); // close the old context > > // Create a new Context > CreateContext(); > } >>
>> public static void savechanges(d060Entities context,out bool success,out string message) >> { >> var s = new StringBuilder(); >> s.Clear(); >> success = true; >> message = ""; >> try >> { >> context.SaveChanges(); >> } >> catch (DbEntityValidationException ex) >> { >> s.AppendLine("DbEntityValidationException."); >> s.AppendFormat("Errors : {0}", ex.EntityValidationErrors.Count()); >> s.AppendLine(); >> foreach (var e in ex.EntityValidationErrors) >> { >> foreach (var e1 in e.ValidationErrors) >> { >> s.AppendFormat(e1.ErrorMessage); >> s.AppendLine(); >> } >> } >> success = false; >> } >> catch (Exception ex) >> { >> s.AppendFormat("error : {0}", ex.ToString()); >> success = false; >> } >> message = s.ToString(); >> } >>