Reputation: 9924
Distinct() can't be apply on some Entities cause some fields can't be hashed (as text field).
Upvotes: 1
Views: 73
Reputation: 9924
After all when Distinct is needed on an EntityObject we only need comparison to be made on the entity key. IEqualityComparer can be implemented like so :
public class EntityObComparer : IEqualityComparer<EntityObject>
{
public bool Equals(EntityObject x, EntityObject y)
{
return x.EntityKey.Equals(y.EntityKey);
}
public int GetHashCode(EntityObject obj)
{
return obj.GetHashCode();
}
}
Then distinct can be perform like so :
var foo = MyListOfEntityObjects.Distinct(new EntityObComparer());
Upvotes: 1