public class DistinctTitle : IEqualityComparer<SourceType> {
public bool Equals(SourceType x, SourceType y) {
return x.title.Equals(y.title);
}
public int GetHashCode(SourceType obj) {
return obj.title.GetHashCode();
}
}
2. Comparer can be used as follows:
var x = (from t in dc.table
where t.sourceId = 5
order by t.itemId descending
select t)
.Distinct(new DistinctTitle())
.Select(t=>new{t.itemId, t.sourceId, t.title });
No comments:
Post a Comment