Пример #1
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);
 }
Пример #2
0
 public RepositoryBase()
 {
     _dbSet = _dbContext.Set <TEntity>();
 }