Example #1
0
 public void Commit()
 {
     try
     {
         _dbContext?.SaveChanges();
     }
     catch (DbEntityValidationException ex)
     {
         throw ex.Format();
     }
 }
Example #2
0
        public void CommitAndRefreshChanges()
        {
            bool saveFailed;

            do
            {
                try
                {
                    _dbContext.SaveChanges();
                    saveFailed = false;
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    saveFailed = true;
                    ex.Entries.ToList()
                    .ForEach(entry => entry.OriginalValues.SetValues(entry.GetDatabaseValues()));
                }
                catch (DbEntityValidationException ex)
                {
                    throw ex.Format();
                }
            } while (saveFailed);
        }