添加类并继承`IEqualityComparer`,重写方法
public class DistinctComparer : IEqualityComparer<ActionInfo>
{
public bool Equals(ActionInfo x, ActionInfo y)
{
return x.ID == y.ID;
} public int GetHashCode(ActionInfo obj)
{
return obj.ID.GetHashCode();
}
}
调用
user_actions.Distinct<ActionInfo>(new DistinctComparer());