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; } }
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; } }
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; } }
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; } }
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; } }
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; } }