public int updUser(Account account) { //新的实体类添加到上下文 fin.Account.Attach(account); //手动修改状态 fin.Entry <Account>(account).State = EntityState.Modified; int result = 0; try { //保存修改 result = fin.SaveChanges(); } catch (Exception ex) { FinanceToError.getFinanceToError().toError(); } return(result); }
/// <summary> /// 修改 /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="entity">以修改的泛型类型对象</param> /// <returns>影响行数</returns> public int comUpd <T>(T entity) where T : class { int result = 0; //新的实体类添加到上下文 fin.Set(entity.GetType()).Attach(entity); //手动修改状态 fin.Entry(entity).State = EntityState.Modified; try { result = fin.SaveChanges(); } catch (Exception ex) { FinanceToError.getFinanceToError().toError(); } return(result); }
/// <summary> /// 修改部门 /// </summary> /// <param name="department">新的部门对象</param> /// <returns>影响行数</returns> public int updDepartment(Department department) { //新的实体类添加到上下文 fin.Department.Attach(department); //手动修改状态 fin.Entry <Department>(department).State = EntityState.Modified; int result = 0; try { //保存修改 result = fin.SaveChanges(); } catch (Exception ex) { FinanceToError.getFinanceToError().toError(); } return(result); }