Example #1
0
        protected virtual async Task SaveUpdateChangesAsync(TEntity entity)
        {
            try
            {
                await DbContext.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                throw UpdateConcurrencyException.From(ex);
            }

            DbContext.Entry(entity).State = EntityState.Detached;
        }
Example #2
0
 protected virtual async Task SaveChangesAndDetachAsync(IEnumerable <TEntity> entities)
 {
     try
     {
         await DbContext.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException ex)
     {
         throw UpdateConcurrencyException.From(ex);
     }
     finally
     {
         foreach (var entity in entities)
         {
             DbContext.Entry(entity).State = EntityState.Detached;
         }
     }
 }