public int Save() { bool saveFailed; do { saveFailed = false; try { return(context.SaveChanges()); } catch (DbUpdateConcurrencyException ex) { saveFailed = true; // Update the values of the entity that failed to save from the store ex.Entries.Single().Reload(); var entry = ex.Entries.Single(); var databaseValues = entry.GetDatabaseValues(); var databaseValuesAsBlog = (CustomerInquiry)databaseValues.ToObject(); // Choose an initial set of resolved values. In this case we // make the default be the values currently in the database. var resolvedValuesAsBlog = (CustomerInquiry)databaseValues.ToObject(); // Have the user choose what the resolved values should be HaveUserResolveConcurrency((CustomerInquiry)entry.Entity, databaseValuesAsBlog, resolvedValuesAsBlog); // Update the original values with the database values and // the current values with whatever the user choose. entry.OriginalValues.SetValues(databaseValues); entry.CurrentValues.SetValues(resolvedValuesAsBlog); } } while (saveFailed); return(0); }
public void Save() { context.SaveChanges(); }
public int Save() { return(context.SaveChanges()); }