我尝试减去 2 个列表,如下面的代码,assignUsers
有 3 条记录并assignedUsers
有 2 行。在Except
方法之后我仍然得到 3 行,虽然我应该得到 1 条记录,因为 2 行assignedUsers
类似于assignUsers
var users = accountApp.GetUsersByAccountId(context.GetUserData().AccountId);
List<AssignUserViewModel> assignUsers = Mapper.Map<List<AssignUserViewModel>>(users).ToList();
var mailUsers = mailApp.GetMailAssignedByMailId(id).Select(m => new { m.UserId, m.User.Name }).ToList();
List<AssignUserViewModel> assignedUsers = mailUsers.Select(Mapper.DynamicMap<AssignUserViewModel>).ToList();
assignUsers = assignUsers.Except(assignedUsers).ToList();