public void CreateList <TEntity>(IList <TEntity> entities) where TEntity : class { using (var context = new RedCarpetDBContext()) { foreach (var entity in entities) { context.SaveChanges(); context.Set <TEntity>().Add(entity); } context.SaveChanges(); } }
public void Create <TEntity>(TEntity entity) where TEntity : class { using (var context = new RedCarpetDBContext()) { context.Set <TEntity>().Add(entity); context.SaveChanges(); } }
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(); } }