public class ProcurementPhotoMenuCompare : IEqualityComparer<ProcurementPhotoMenuModel> { public bool Equals(ProcurementPhotoMenuModel x, ProcurementPhotoMenuModel y) { return (x.CategoryType == y.CategoryType); } public int GetHashCode(ProcurementPhotoMenuModel obj) { return obj.ToString().ToLower().GetHashCode(); } }
使用;
return m.Select(t => new ProcurementPhotoMenuModel { CategoryType = t.Identifier ?? "", MenuTitle = t.Title ?? "", PhotoMenuType = t.Attribute01 ?? "" }).Distinct(new ProcurementPhotoMenuCompare()).ToList();