I have this class
public class Item
{
public Coordinate coordinate { get; set; }
...
...
}
With Coordinate being def
You've shown the Equals implementation, but not GetHashCode. You need to override both (and in a consistent way) for grouping to work.
Sample GetHashCode implementation:
public override int GetHashCode()
{
int hash = 23;
hash = hash * 31 + Latitude.GetHashCode();
hash = hash * 31 + Longitude.GetHashCode();
return hash;
}
Note that comparing float
values for exact equality is always somewhat risky - but I'd at least expect your unit tests to pass, given that they're not performing any calculations.