Esempio n. 1
0
 public int Update(TEntity entity)
 {
     dbcontext.Set <TEntity>().Attach(entity);
     PropertyInfo[] props = entity.GetType().GetProperties();
     foreach (PropertyInfo prop in props)
     {
         if (prop.GetValue(entity, null) != null)
         {
             if (prop.GetValue(entity, null).ToString() == "&nbsp;")
             {
                 dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null;
             }
             dbcontext.Entry(entity).Property(prop.Name).IsModified = true;
         }
     }
     return(dbcontext.SaveChanges());
 }
Esempio n. 2
0
 public int Update <TEntity>(TEntity entity) where TEntity : class
 {
     dbcontext.Set <TEntity>().Attach(entity);
     PropertyInfo[] props = entity.GetType().GetProperties();
     foreach (PropertyInfo prop in props)
     {
         if (prop.GetValue(entity, null) != null)
         {
             if (prop.GetValue(entity, null).ToString() == "&nbsp;")
             {
                 dbcontext.Entry(entity).Property(prop.Name).CurrentValue = null;
             }
             dbcontext.Entry(entity).Property(prop.Name).IsModified = true;
         }
     }
     return(dbTransaction == null?this.Commit() : 0);
 }