public void Update <TEntity>(TEntity entity) where TEntity : class { using (var context = new RedCarpetDBContext()) { context.Set <TEntity>().Attach(entity); context.Entry(entity).State = EntityState.Modified; context.SaveChanges(); } }
public void UpdateList <TEntity>(IList <TEntity> entities) where TEntity : class { using (var context = new RedCarpetDBContext()) { foreach (var entity in entities) { context.Set <TEntity>().Attach(entity); context.Entry(entity).State = EntityState.Modified; } context.SaveChanges(); } }