1.调用:
UserList = UserList.ToList().Intersect(userIDList, new MyUserComparer()).AsQueryable();
2.须要重写的方法:
public class MyUserComparer : IEqualityComparer<MyUser> { public bool Equals(MyUser x, MyUser y) { //throw new NotImplementedException(); return x.UserID == y.UserID; } public int GetHashCode(MyUser obj) { return obj.ToString().GetHashCode(); } }
时间: 2024-12-29 05:11:50