Пример #1
0
 public void Update(TEntity parameter)
 {
     using (var context = new HSERPEntities(_connectString))
     {
         try
         {
             context.Set <TEntity>().Attach(parameter);
             context.Entry(parameter).State = EntityState.Modified;
             context.SaveChanges();
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.Message);
         }
     }
 }
Пример #2
0
 public TEntity Insert(TEntity parameter)
 {
     using (var context = new HSERPEntities(_connectString))
     {
         try
         {
             var para = context.Set <TEntity>().Add(parameter);
             context.SaveChanges();
             return(para);
         }
         catch (DbUpdateException e)
         {
             Console.WriteLine(e.InnerException.Message);
             return(null);
         }
     }
 }
        public void Insert(List <TEntity> parameters)
        {
            using (var context = new HSERPEntities(_connectString))
            {
                try
                {
                    foreach (var info in parameters)
                    {
                        context.Set <TEntity>().Add(info);
                    }

                    context.SaveChanges();
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine(e.InnerException.Message);
                }
            }
        }
        public void Update(List <TEntity> parameters)
        {
            using (var context = new HSERPEntities(_connectString))
            {
                try
                {
                    foreach (var info in parameters)
                    {
                        context.Set <TEntity>().Attach(info);
                        context.Entry(info).State = EntityState.Modified;
                    }

                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
        }
Пример #5
0
 public void Save(HSERPEntities context)
 {
     context.SaveChanges();
 }
Пример #6
0
 private void Save(HSERPEntities context)
 {
     context.SaveChanges();
 }