예제 #1
0
 public static bool UpdateEntity <T>(List <T> pEntity, galadbEntities pContext) where T : class
 {
     try
     {
         foreach (T _entity in pEntity)
         {
             try
             {
                 if (pContext.Entry(_entity).State == EntityState.Detached)
                 {
                     pContext.Set <T>().Attach(_entity);
                 }
                 pContext.Entry(_entity).State = EntityState.Modified;
             }
             catch
             {
                 continue;
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        public static bool RemoveInsertEntity <T>(List <T> pEntity) where T : class
        {
            try
            {
                using (galadbEntities context = new galadbEntities())
                {
                    foreach (T _entity in pEntity)     // suppression des habilitation dans la base
                    {
                        if (context.Entry(_entity).State == EntityState.Detached)
                        {
                            context.Set <T>().Attach(_entity);
                            context.Set <T>().Remove(_entity);
                        }
                    }
                    context.SaveChanges();

                    foreach (T _entity in pEntity)     // suppression des habilitation dans la base
                    {
                        if (context.Entry(_entity).State == EntityState.Detached)
                        {
                            context.Set <T>().Attach(_entity);
                            context.Set <T>().Remove(_entity);
                        }
                    }
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        public static bool UpdateEntity <T>(T pEntity, galadbEntities pContext) where T : class
        {
            try
            {
                if (pContext.Entry(pEntity).State == EntityState.Detached)
                {
                    pContext.Set <T>().Attach(pEntity);
                }

                pContext.Entry(pEntity).State = EntityState.Modified;
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
 public static bool UpdateEntity <T>(T entity) where T : class
 {
     try
     {
         using (galadbEntities context = new galadbEntities())
         {
             if (context.Entry(entity).State == EntityState.Detached)
             {
                 context.Set <T>().Attach(entity);
                 context.Entry(entity).State = EntityState.Modified;
                 context.SaveChanges();
                 return(true);
             }
         }
         return(false);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
 public static bool InsertEntity <T>(T entity, galadbEntities pContext) where T : class
 {
     try
     {
         if (pContext.Entry(entity).State == EntityState.Detached)
         {
             pContext.Set <T>().Add(entity);
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
 public static bool InsertEntity <T>(List <T> pEntity) where T : class
 {
     try
     {
         using (galadbEntities context = new galadbEntities())
         {
             foreach (T _entity in pEntity)
             {
                 if (context.Entry(_entity).State == EntityState.Detached)
                 {
                     context.Set <T>().Add(_entity);
                 }
             }
             context.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }