public void RemoveUsersFromGroups(UserBase[] users, int[] groupIds) { if (ArrayIsNullOrEmpty(users) || ArrayIsNullOrEmpty(groupIds)) { throw new ArgumentNullException("users,groupIds", "Users or UserGroups can not be null or empty!"); } this._session.BeginTransaction(); try { foreach (int gid in groupIds) { UserGroup group = UserGroup.Retrieve(_session, gid); if (!group.RemoveUserFromGroup(users, this._session)) { throw new ApplicationException(string.Format("从用户组{0}中移出用户失败!", group.Name)); } } _session.Commit(); } catch { this._session.Rollback(); throw; } }