/// <summary> /// 删除用户 /// </summary> /// <param name="models"></param> public void RemoveUserTable(UserTableViewModel models) { using (var db = new AALifeDbContext()) { var userTable = models.Adapt <UserTable>(); db.Entry <UserTable>(userTable).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
/// <summary> /// 更新用户--批量 /// </summary> /// <param name="models"></param> public void UpdateUserTable(List <UserTableViewModel> models) { using (var db = new AALifeDbContext()) { models.ForEach((model) => { var userTable = model.Adapt <UserTable>(); db.Entry <UserTable>(userTable).State = System.Data.Entity.EntityState.Modified; }); db.SaveChanges(); } }