score:3

Accepted answer

the problem is impossible, conceptually. you're trying to compare objects in a way that doesn't have a form of equality that is necessary for the operations you're trying to perform with it. for example, groupjoin is dependant on the assumption that if a is equal to b, and b is equal to c, then a is equal to c, but in your situation, that's not true. a and b may be "close enough" together for you to want to group them, but a and c may not be.

you're going to need to not implement iequalitycomparer at all, because you cannot fulfill the contract that it requires. if you want to create a mapping of items in one collection to all of the items in another collection that are "close enough" to it then you're going to need to write that algorithm yourself (doing so efficiently is likely to be hard, but doing so inefficiently isn't shouldn't' be that difficult), rather than using groupjoin, because it's not capable of performing that operation.

score:1

i can't see any way to generate a logical hash code for your given criteria.
the hash code is used to determine if 2 dates should stick together. if they should group together, than they must return the same hash code.

if your "float" is 5 days, that means that 1/1/2000 must generate the same hash code as 1/4/2000, and 1/4/2000 must generate the same hashcode as 1/8/2000 (since they are both within 5 days of each other). that implies that 1/1/2000 has the same code as 1/8/2000 (since if a=b and b=c, a=c).

1/1/2000 and 1/8/2000 are outside the 5 day "float".


Related Query

More Query from same tag