//삽입 public void Insert(T entity) { using (PCBVIEntities context = DbContextFactory.Create()) { context.Set <T>().Add(entity); context.SaveChanges(); } }
//삭제 public void Delete(T entity) { using (PCBVIEntities context = DbContextFactory.Create()) { context.Entry(entity).State = EntityState.Deleted; context.SaveChanges(); } }
//리스트 등록 public void InsertALL(List <T> entiList) { using (PCBVIEntities context = DbContextFactory.Create()) { entiList.ForEach(n => context.Set <T>().Add(n)); context.SaveChanges(); // companies.ForEach(n => context.AddToCompanies(n)); } }
public bool InsertOrUpdate(Barcode barcode) { using (PCBVIEntities context = new PCBVIEntities()) { context.Entry(barcode).State = barcode.BarcodeId != 0 ? EntityState.Modified : EntityState.Added; try { context.SaveChanges(); } catch (Exception e) { if (e != null) { return(false); } } return(true); } }