Ejemplo n.º 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;
        }
Ejemplo n.º 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;
         }
     }
 }