Exemple #1
0
 //삽입
 public void Insert(T entity)
 {
     using (PCBVIEntities context = DbContextFactory.Create())
     {
         context.Set <T>().Add(entity);
         context.SaveChanges();
     }
 }
Exemple #2
0
        //삭제
        public void Delete(T entity)
        {
            using (PCBVIEntities context = DbContextFactory.Create())
            {
                context.Entry(entity).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
Exemple #3
0
        //리스트 등록

        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));
            }
        }
Exemple #4
0
        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);
            }
        }