Ejemplo n.º 1
0
 /// <summary>
 /// 添加一条模型记录,自动提交更改
 /// </summary>
 public virtual bool Save(T entity)
 {
     try
     {
         int row   = 0;
         var entry = _dbContext.Entry <T>(entity);
         entry.State = EntityState.Added;
         row         = _dbContext.SaveChanges();
         entry.State = EntityState.Detached;
         return(row > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 2
0
        public bool UpdateStatus(int execTaskId, int statusId, DateTime endTime)
        {
            ExecTaskTable _etable = _dbcontext.ExecTaskTable.FirstOrDefault(p => p.Id == execTaskId);

            if (_etable != null)
            {
                _etable.TaskStateTableId = statusId;
                if (endTime != null && endTime.Year != 1)
                {
                    _etable.EndTime = endTime;
                }
                var entity = _dbcontext.Entry(_etable);
                entity.State = EntityState.Modified;
                int row = _dbcontext.SaveChanges();
                entity.State = EntityState.Detached;
                return(row == 1);
            }
            else
            {
                return(false);
            }
        }