Ejemplo n.º 1
0
 public static void Add(this ApplicationEntitie db, object entity)
 {
     try
     {
         if (db.Entry(entity).State != EntityState.Added)
         {
             db.Entry(entity).State = EntityState.Added;
         }
     }
     catch (Exception e)
     {
         DBException.WriteLog(e);
     }
 }
Ejemplo n.º 2
0
 public static void Refresh <T>(this ApplicationEntitie db) where T : class
 {
     foreach (var entity in db.Set <T>())
     {
         db.Entry(entity).State = EntityState.Detached;
     }
     db.Set <T>().Load();
 }
Ejemplo n.º 3
0
 public static void Remove(this ApplicationEntitie db, object entity)
 {
     try
     {
         if (db.Entry(entity).State == EntityState.Added)
         {
             db.Entry(entity).State = EntityState.Detached;
         }
         else if (db.Entry(entity).State != EntityState.Deleted)
         {
             db.Entry(entity).State = EntityState.Deleted;
         }
     }
     catch (Exception e)
     {
         DBException.WriteLog(e);
     }
 }
Ejemplo n.º 4
0
 public static bool CheckExist(this ApplicationEntitie db, object entity)
 {
     try
     {
         if (db.Entry(entity).State != EntityState.Detached)
         {
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public static void Refresh(this ApplicationEntitie db, object instance)
 {
     db.Entry(instance).Reload();
 }